@@ -2969,35 +2969,34 @@ SILValue LifetimeChecker::handleConditionalInitAssign() {
2969
2969
2970
2970
// Create the control variable as the first instruction in the function (so
2971
2971
// that it is easy to destroy the stack location.
2972
- SILBuilder B (TheMemory.getFunctionEntryPoint ());
2973
- B.setCurrentDebugScope (TheMemory.getFunction ().getDebugScope ());
2974
2972
SILType IVType =
2975
2973
SILType::getBuiltinIntegerType (NumMemoryElements, Module.getASTContext ());
2976
2974
// Use an empty location for the alloc_stack. If Loc is variable declaration
2977
2975
// the alloc_stack would look like the storage of that variable.
2978
- auto *ControlVariableBox = B.createAllocStack (
2979
- RegularLocation::getAutoGeneratedLocation (), IVType);
2976
+ auto *ControlVariableBox =
2977
+ SILBuilderWithScope (TheMemory.getFunctionEntryPoint ())
2978
+ .createAllocStack (RegularLocation::getAutoGeneratedLocation (),
2979
+ IVType);
2980
2980
2981
2981
// Find all the return blocks in the function, inserting a dealloc_stack
2982
2982
// before the return.
2983
2983
for (auto &BB : TheMemory.getFunction ()) {
2984
2984
auto *Term = BB.getTerminator ();
2985
2985
if (Term->isFunctionExiting ()) {
2986
- B.setInsertionPoint (Term);
2987
- B.setCurrentDebugScope (Term->getDebugScope ());
2988
- B.createDeallocStack (Loc, ControlVariableBox);
2986
+ SILBuilderWithScope (Term).createDeallocStack (Loc, ControlVariableBox);
2989
2987
}
2990
2988
}
2991
2989
2992
2990
// Before the memory allocation, store zero in the control variable.
2993
- auto *InsertPoint =
2994
- &*std::next (TheMemory.getUninitializedValue ()->getIterator ());
2995
- B.setInsertionPoint (InsertPoint);
2996
- B.setCurrentDebugScope (InsertPoint->getDebugScope ());
2997
2991
SILValue ControlVariableAddr = ControlVariableBox;
2998
- auto Zero = B.createIntegerLiteral (Loc, IVType, 0 );
2999
- B.createStore (Loc, Zero, ControlVariableAddr,
3000
- StoreOwnershipQualifier::Trivial);
2992
+ {
2993
+ auto *InsertPoint =
2994
+ &*std::next (TheMemory.getUninitializedValue ()->getIterator ());
2995
+ SILBuilderWithScope B (InsertPoint);
2996
+ auto Zero = B.createIntegerLiteral (Loc, IVType, 0 );
2997
+ B.createStore (Loc, Zero, ControlVariableAddr,
2998
+ StoreOwnershipQualifier::Trivial);
2999
+ }
3001
3000
3002
3001
Identifier OrFn;
3003
3002
@@ -3021,7 +3020,7 @@ SILValue LifetimeChecker::handleConditionalInitAssign() {
3021
3020
Use.onlyTouchesTrivialElements (TheMemory))
3022
3021
continue ;
3023
3022
3024
- B. setInsertionPoint (Use.Inst );
3023
+ SILBuilderWithScope B (Use.Inst );
3025
3024
3026
3025
// Only full initializations make something live. inout uses, escapes, and
3027
3026
// assignments only happen when some kind of init made the element live.
@@ -3110,7 +3109,7 @@ SILValue LifetimeChecker::handleConditionalInitAssign() {
3110
3109
if (HasConditionalSelfInitialized) {
3111
3110
for (auto *I : StoresToSelf) {
3112
3111
auto *bb = I->getParent ();
3113
- B. setInsertionPoint (bb->begin ());
3112
+ SILBuilderWithScope B (bb->begin ());
3114
3113
3115
3114
// Set the most significant bit.
3116
3115
APInt Bitmask = APInt::getHighBitsSet (NumMemoryElements, 1 );
0 commit comments