@@ -98,7 +98,7 @@ SILInstruction *CastOptimizer::optimizeBridgedObjCToSwiftCast(
98
98
CanType CanBridgedTy = BridgedTargetTy->getCanonicalType ();
99
99
SILType SILBridgedTy = SILType::getPrimitiveObjectType (CanBridgedTy);
100
100
101
- SILBuilderWithScope Builder (Inst);
101
+ SILBuilderWithScope Builder (Inst, BuilderContext );
102
102
SILValue SrcOp;
103
103
SILInstruction *NewI = nullptr ;
104
104
@@ -349,7 +349,7 @@ SILInstruction *CastOptimizer::optimizeBridgedSwiftToObjCCast(
349
349
(void )Conf;
350
350
351
351
// Generate code to invoke _bridgeToObjectiveC
352
- SILBuilderWithScope Builder (Inst);
352
+ SILBuilderWithScope Builder (Inst, BuilderContext );
353
353
354
354
auto *NTD = Source.getNominalOrBoundGenericNominal ();
355
355
assert (NTD);
@@ -702,7 +702,7 @@ SILInstruction *CastOptimizer::simplifyCheckedCastAddrBranchInst(
702
702
auto *FailureBB = Inst->getFailureBB ();
703
703
auto &Mod = Inst->getModule ();
704
704
705
- SILBuilderWithScope Builder (Inst);
705
+ SILBuilderWithScope Builder (Inst, BuilderContext );
706
706
707
707
// Try to determine the outcome of the cast from a known type
708
708
// to a protocol type at compile-time.
@@ -816,7 +816,7 @@ CastOptimizer::simplifyCheckedCastBranchInst(CheckedCastBranchInst *Inst) {
816
816
return nullptr ;
817
817
818
818
// We know the dynamic type of the operand.
819
- SILBuilderWithScope Builder (Inst);
819
+ SILBuilderWithScope Builder (Inst, BuilderContext );
820
820
auto Loc = Inst->getLoc ();
821
821
auto *SuccessBB = Inst->getSuccessBB ();
822
822
auto *FailureBB = Inst->getFailureBB ();
@@ -858,7 +858,7 @@ CastOptimizer::simplifyCheckedCastBranchInst(CheckedCastBranchInst *Inst) {
858
858
auto Feasibility = classifyDynamicCast (Mod.getSwiftModule (), SourceType,
859
859
TargetType, isSourceTypeExact);
860
860
861
- SILBuilderWithScope Builder (Inst);
861
+ SILBuilderWithScope Builder (Inst, BuilderContext );
862
862
863
863
if (Feasibility == DynamicCastFeasibility::WillFail) {
864
864
auto *NewI = Builder.createBranch (Loc, FailureBB);
@@ -943,7 +943,7 @@ SILInstruction *CastOptimizer::simplifyCheckedCastValueBranchInst(
943
943
auto Feasibility = classifyDynamicCast (Mod.getSwiftModule (), SourceType,
944
944
TargetType, isSourceTypeExact);
945
945
946
- SILBuilderWithScope Builder (Inst);
946
+ SILBuilderWithScope Builder (Inst, BuilderContext );
947
947
948
948
if (Feasibility == DynamicCastFeasibility::WillFail) {
949
949
auto *NewI = Builder.createBranch (Loc, FailureBB);
@@ -1065,7 +1065,7 @@ SILInstruction *CastOptimizer::optimizeCheckedCastAddrBranchInst(
1065
1065
canUseScalarCheckedCastInstructions (
1066
1066
Inst->getModule (), MI->getType ().getASTType (),
1067
1067
Inst->getTargetType ())) {
1068
- SILBuilderWithScope B (Inst);
1068
+ SILBuilderWithScope B (Inst, BuilderContext );
1069
1069
auto NewI = B.createCheckedCastBranch (
1070
1070
Loc, false /* isExact*/ , MI, Dest->getType ().getObjectType (),
1071
1071
SuccessBB, FailureBB, Inst->getTrueBBCount (),
@@ -1114,7 +1114,7 @@ CastOptimizer::optimizeCheckedCastBranchInst(CheckedCastBranchInst *Inst) {
1114
1114
// checked_cast_br %0 to ...
1115
1115
if (auto *IEMI = dyn_cast<InitExistentialMetatypeInst>(Op)) {
1116
1116
if (auto *MI = dyn_cast<MetatypeInst>(IEMI->getOperand ())) {
1117
- SILBuilderWithScope B (Inst);
1117
+ SILBuilderWithScope B (Inst, BuilderContext );
1118
1118
auto *NewI = B.createCheckedCastBranch (
1119
1119
Loc, /* isExact */ false , MI, LoweredTargetType, SuccessBB, FailureBB,
1120
1120
Inst->getTrueBBCount (), Inst->getFalseBBCount ());
@@ -1177,7 +1177,7 @@ CastOptimizer::optimizeCheckedCastBranchInst(CheckedCastBranchInst *Inst) {
1177
1177
EMT->getRepresentation ());
1178
1178
auto CanMetaTy = CanTypeWrapper<MetatypeType>(MetaTy);
1179
1179
auto SILMetaTy = SILType::getPrimitiveObjectType (CanMetaTy);
1180
- SILBuilderWithScope B (Inst);
1180
+ SILBuilderWithScope B (Inst, BuilderContext );
1181
1181
B.getOpenedArchetypes ().addOpenedArchetypeOperands (
1182
1182
FoundIEI->getTypeDependentOperands ());
1183
1183
auto *MI = B.createMetatype (FoundIEI->getLoc (), SILMetaTy);
@@ -1236,7 +1236,7 @@ CastOptimizer::optimizeCheckedCastBranchInst(CheckedCastBranchInst *Inst) {
1236
1236
auto *MetaTy = MetatypeType::get (ConcreteTy, EMT->getRepresentation ());
1237
1237
auto CanMetaTy = CanTypeWrapper<MetatypeType>(MetaTy);
1238
1238
auto SILMetaTy = SILType::getPrimitiveObjectType (CanMetaTy);
1239
- SILBuilderWithScope B (Inst);
1239
+ SILBuilderWithScope B (Inst, BuilderContext );
1240
1240
B.getOpenedArchetypes ().addOpenedArchetypeOperands (
1241
1241
FoundIERI->getTypeDependentOperands ());
1242
1242
auto *MI = B.createMetatype (FoundIERI->getLoc (), SILMetaTy);
@@ -1271,7 +1271,7 @@ ValueBase *CastOptimizer::optimizeUnconditionalCheckedCastInst(
1271
1271
if (Feasibility == DynamicCastFeasibility::WillFail) {
1272
1272
// Remove the cast and insert a trap, followed by an
1273
1273
// unreachable instruction.
1274
- SILBuilderWithScope Builder (Inst);
1274
+ SILBuilderWithScope Builder (Inst, BuilderContext );
1275
1275
auto *Trap = Builder.createBuiltinTrap (Loc);
1276
1276
Inst->replaceAllUsesWithUndef ();
1277
1277
EraseInstAction (Inst);
@@ -1296,7 +1296,7 @@ ValueBase *CastOptimizer::optimizeUnconditionalCheckedCastInst(
1296
1296
}
1297
1297
}
1298
1298
1299
- SILBuilderWithScope Builder (Inst);
1299
+ SILBuilderWithScope Builder (Inst, BuilderContext );
1300
1300
1301
1301
// Try to apply the bridged casts optimizations
1302
1302
auto SourceType = LoweredSourceType.getASTType ();
@@ -1481,7 +1481,7 @@ SILInstruction *CastOptimizer::optimizeUnconditionalCheckedCastAddrInst(
1481
1481
if (Feasibility == DynamicCastFeasibility::WillFail) {
1482
1482
// Remove the cast and insert a trap, followed by an
1483
1483
// unreachable instruction.
1484
- SILBuilderWithScope Builder (Inst);
1484
+ SILBuilderWithScope Builder (Inst, BuilderContext );
1485
1485
// mem2reg's invariants get unhappy if we don't try to
1486
1486
// initialize a loadable result.
1487
1487
auto DestType = Dest->getType ();
@@ -1529,7 +1529,7 @@ SILInstruction *CastOptimizer::optimizeUnconditionalCheckedCastAddrInst(
1529
1529
}
1530
1530
1531
1531
if (ResultNotUsed) {
1532
- SILBuilderWithScope B (Inst);
1532
+ SILBuilderWithScope B (Inst, BuilderContext );
1533
1533
B.createDestroyAddr (Inst->getLoc (), Inst->getSrc ());
1534
1534
if (DestroyDestInst)
1535
1535
EraseInstAction (DestroyDestInst);
@@ -1561,7 +1561,7 @@ SILInstruction *CastOptimizer::optimizeUnconditionalCheckedCastAddrInst(
1561
1561
if (isBridgingCast (SourceType, TargetType))
1562
1562
return nullptr ;
1563
1563
1564
- SILBuilderWithScope Builder (Inst);
1564
+ SILBuilderWithScope Builder (Inst, BuilderContext );
1565
1565
if (!emitSuccessfulIndirectUnconditionalCast (Builder, Mod.getSwiftModule (),
1566
1566
Loc, Src, SourceType, Dest,
1567
1567
TargetType, Inst)) {
@@ -1596,19 +1596,21 @@ SILInstruction *CastOptimizer::optimizeMetatypeConversion(
1596
1596
return NewCast;
1597
1597
};
1598
1598
if (auto *MI = dyn_cast<MetatypeInst>(Op)) {
1599
- return replaceCast (
1600
- SILBuilderWithScope (MCI) .createMetatype (MCI->getLoc (), Ty));
1599
+ return replaceCast (SILBuilderWithScope (MCI, BuilderContext)
1600
+ .createMetatype (MCI->getLoc (), Ty));
1601
1601
}
1602
1602
// For metatype instructions that require an operand, generate the new
1603
1603
// metatype at the same position as the original to avoid extending the
1604
1604
// lifetime of `Op` past its destroy.
1605
1605
if (auto *VMI = dyn_cast<ValueMetatypeInst>(Op)) {
1606
- return replaceCast (SILBuilderWithScope (VMI).createValueMetatype (
1607
- MCI->getLoc (), Ty, VMI->getOperand ()));
1606
+ return replaceCast (
1607
+ SILBuilderWithScope (VMI, BuilderContext)
1608
+ .createValueMetatype (MCI->getLoc (), Ty, VMI->getOperand ()));
1608
1609
}
1609
1610
if (auto *EMI = dyn_cast<ExistentialMetatypeInst>(Op)) {
1610
- return replaceCast (SILBuilderWithScope (EMI).createExistentialMetatype (
1611
- MCI->getLoc (), Ty, EMI->getOperand ()));
1611
+ return replaceCast (
1612
+ SILBuilderWithScope (EMI, BuilderContext)
1613
+ .createExistentialMetatype (MCI->getLoc (), Ty, EMI->getOperand ()));
1612
1614
}
1613
1615
return nullptr ;
1614
1616
}
0 commit comments