@@ -519,8 +519,10 @@ SILValue AvailableValueAggregator::handlePrimitiveValue(SILType LoadTy,
519
519
// case.
520
520
ArrayRef<SILInstruction *> InsertPts = Val.getInsertionPoints ();
521
521
if (InsertPts.size () == 1 ) {
522
- SavedInsertionPointRAII SavedInsertPt (B, InsertPts[0 ]);
523
- SILValue EltVal = nonDestructivelyExtractSubElement (Val, B, Loc);
522
+ // Use the scope and location of the store at the insertion point.
523
+ SILBuilderWithScope Builder (InsertPts[0 ]);
524
+ SILLocation Loc = InsertPts[0 ]->getLoc ();
525
+ SILValue EltVal = nonDestructivelyExtractSubElement (Val, Builder, Loc);
524
526
assert (EltVal->getType () == LoadTy && " Subelement types mismatch" );
525
527
return EltVal;
526
528
}
@@ -530,8 +532,10 @@ SILValue AvailableValueAggregator::handlePrimitiveValue(SILType LoadTy,
530
532
SILSSAUpdater Updater;
531
533
Updater.Initialize (LoadTy);
532
534
for (auto *I : Val.getInsertionPoints ()) {
533
- SavedInsertionPointRAII SavedInsertPt (B, I);
534
- SILValue EltVal = nonDestructivelyExtractSubElement (Val, B, Loc);
535
+ // Use the scope and location of the store at the insertion point.
536
+ SILBuilderWithScope Builder (I);
537
+ SILLocation Loc = I->getLoc ();
538
+ SILValue EltVal = nonDestructivelyExtractSubElement (Val, Builder, Loc);
535
539
Updater.AddAvailableValue (I->getParent (), EltVal);
536
540
}
537
541
@@ -1113,7 +1117,7 @@ bool AllocOptimize::promoteLoad(SILInstruction *Inst) {
1113
1117
}
1114
1118
1115
1119
// Aggregate together all of the subelements into something that has the same
1116
- // type as the load did, and emit smaller) loads for any subelements that were
1120
+ // type as the load did, and emit smaller loads for any subelements that were
1117
1121
// not available.
1118
1122
auto *Load = cast<LoadInst>(Inst);
1119
1123
AvailableValueAggregator Agg (Load, AvailableValues, Uses);
0 commit comments