diff options
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 146f54932..7621f3080 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -7661,23 +7661,20 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // // if(!isInitialized) { <globalVal> = <initExpr>; isInitialized = true; } // - // TODO: we could conceivably optimize this by detecting - // when the `initExpr` lowers to just a reference to a constant, - // and then either deleting the extra code structure there, - // or not generating it in the first place. That is a bit - // more complexity than I'm ready for at the moment. + // This will generate a lot of boilterplate code, but we optimize out the + // boilerplate functions later during `moveGlobalVarInitializationToEntryPoints` + // if we see the init function is just returning a global constant. // auto boolBuilder = subBuilder; auto irBoolType = boolBuilder->getBoolType(); auto irBool = boolBuilder->createGlobalVar(irBoolType); boolBuilder->setInsertInto(irBool); - boolBuilder->setInsertInto(boolBuilder->createBlock()); + boolBuilder->emitBlock(); boolBuilder->emitReturn(boolBuilder->getBoolValue(false)); auto boolVal = LoweredValInfo::ptr(irBool); - // Okay, with our global Boolean created, we can move on to // generating the code we actually care about, back in the original function. |
