diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-10-30 14:21:34 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-30 14:21:34 -0700 |
| commit | 098dd5d87ef73528a14b5478616967f16f73a9ad (patch) | |
| tree | cecb84ae7d3b9c09c3eb239f7f7bdebb2215cc1a /source/slang/lower-to-ir.cpp | |
| parent | baf06088dff0b961843ad03efd75ff009befec5c (diff) | |
Fix a crash on function-static variables with initializers (#703)
This code path hadn't been used, and it had a crash due to not inserting the basic blocks it created (for initializing the variable) into the parent function. The fix adds a bit more smarts to the `IRBuilder` to help with inserting basic blocks into the flow of a function.
The actual user issue was around `static const` declarations, and it is clear that the code is incorrectly treating a function local `static const` as if it were just `static`. That will need to be fixed in another change.
Diffstat (limited to 'source/slang/lower-to-ir.cpp')
| -rw-r--r-- | source/slang/lower-to-ir.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp index 6cce469ea..806654ccb 100644 --- a/source/slang/lower-to-ir.cpp +++ b/source/slang/lower-to-ir.cpp @@ -4012,18 +4012,19 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // generating the code we actually care about, back in the original function. auto builder = getBuilder(); + auto initBlock = builder->createBlock(); auto afterBlock = builder->createBlock(); builder->emitIfElse(getSimpleVal(context, boolVal), afterBlock, initBlock, afterBlock); - builder->setInsertInto(initBlock); + builder->insertBlock(initBlock); LoweredValInfo initVal = lowerLValueExpr(context, initExpr); assign(context, globalVal, initVal); assign(context, boolVal, LoweredValInfo::simple(builder->getBoolValue(true))); builder->emitBranch(afterBlock); - builder->setInsertInto(afterBlock); + builder->insertBlock(afterBlock); } irGlobal->moveToEnd(); |
