@@ -1269,6 +1269,9 @@ class AddressMaterialization {
1269
1269
// /
1270
1270
// / If the operand projects into its use, then the memory was already
1271
1271
// / initialized when visiting the use.
1272
+ // /
1273
+ // / It's ok for the builder to reuse the user's SILLocation because
1274
+ // / initializeComposingUse always inserts code immediately before the user.
1272
1275
void AddressMaterialization::initializeComposingUse (Operand *operand) {
1273
1276
SILValue def = operand->get ();
1274
1277
if (def->getType ().isAddressOnly (*pass.function )) {
@@ -1405,15 +1408,15 @@ SILValue AddressMaterialization::materializeStructExtract(
1405
1408
SILValue srcAddr = pass.getMaterializedAddress (structVal);
1406
1409
auto *structType = structVal->getType ().getStructOrBoundGenericStruct ();
1407
1410
auto *varDecl = structType->getStoredProperties ()[fieldIdx];
1408
- return B.createStructElementAddr (extractInst-> getLoc (), srcAddr, varDecl,
1411
+ return B.createStructElementAddr (pass. genLoc (), srcAddr, varDecl,
1409
1412
elementValue->getType ().getAddressType ());
1410
1413
}
1411
1414
1412
1415
// \p tupleInst is a unary instruction whose first operand is a tuple.
1413
1416
SILValue AddressMaterialization::materializeTupleExtract (
1414
1417
SILInstruction *extractInst, SILValue elementValue, unsigned fieldIdx) {
1415
1418
SILValue srcAddr = pass.getMaterializedAddress (extractInst->getOperand (0 ));
1416
- return B.createTupleElementAddr (extractInst-> getLoc (), srcAddr, fieldIdx,
1419
+ return B.createTupleElementAddr (pass. genLoc (), srcAddr, fieldIdx,
1417
1420
elementValue->getType ().getAddressType ());
1418
1421
}
1419
1422
@@ -1431,7 +1434,7 @@ AddressMaterialization::materializeProjectionIntoUse(Operand *operand,
1431
1434
case SILInstructionKind::EnumInst: {
1432
1435
auto *enumInst = cast<EnumInst>(user);
1433
1436
SILValue enumAddr = materializeComposingUser (enumInst, intoPhiOperand);
1434
- return B.createInitEnumDataAddr (enumInst-> getLoc (), enumAddr,
1437
+ return B.createInitEnumDataAddr (pass. genLoc (), enumAddr,
1435
1438
enumInst->getElement (),
1436
1439
operand->get ()->getType ().getAddressType ());
1437
1440
}
@@ -1443,8 +1446,8 @@ AddressMaterialization::materializeProjectionIntoUse(Operand *operand,
1443
1446
auto opaque = Lowering::AbstractionPattern::getOpaque ();
1444
1447
auto &concreteTL = pass.function ->getTypeLowering (opaque, canTy);
1445
1448
return B.createInitExistentialAddr (
1446
- initExistentialValue-> getLoc (), containerAddr, canTy,
1447
- concreteTL.getLoweredType (), initExistentialValue->getConformances ());
1449
+ pass. genLoc (), containerAddr, canTy,
1450
+ concreteTL.getLoweredType (), initExistentialValue->getConformances ());
1448
1451
}
1449
1452
case SILInstructionKind::StructInst: {
1450
1453
auto *structInst = cast<StructInst>(user);
@@ -1454,8 +1457,8 @@ AddressMaterialization::materializeProjectionIntoUse(Operand *operand,
1454
1457
1455
1458
SILValue structAddr = materializeComposingUser (structInst, intoPhiOperand);
1456
1459
return B.createStructElementAddr (
1457
- structInst-> getLoc (), structAddr, *fieldIter,
1458
- operand->get ()->getType ().getAddressType ());
1460
+ pass. genLoc (), structAddr, *fieldIter,
1461
+ operand->get ()->getType ().getAddressType ());
1459
1462
}
1460
1463
case SILInstructionKind::TupleInst: {
1461
1464
auto *tupleInst = cast<TupleInst>(user);
@@ -1467,7 +1470,7 @@ AddressMaterialization::materializeProjectionIntoUse(Operand *operand,
1467
1470
return pass.function ->getArguments ()[resultIdx];
1468
1471
}
1469
1472
SILValue tupleAddr = materializeComposingUser (tupleInst, intoPhiOperand);
1470
- return B.createTupleElementAddr (tupleInst-> getLoc (), tupleAddr,
1473
+ return B.createTupleElementAddr (pass. genLoc (), tupleAddr,
1471
1474
operand->getOperandNumber (),
1472
1475
operand->get ()->getType ().getAddressType ());
1473
1476
}
@@ -2739,7 +2742,7 @@ void UseRewriter::visitSwitchEnumInst(SwitchEnumInst * switchEnum) {
2739
2742
auto *caseAddr =
2740
2743
caseBuilder.createUncheckedTakeEnumDataAddr (loc, enumAddr, caseDecl);
2741
2744
auto *caseLoad = caseBuilder.createTrivialLoadOr (
2742
- switchEnum-> getLoc () , caseAddr, LoadOwnershipQualifier::Take);
2745
+ loc , caseAddr, LoadOwnershipQualifier::Take);
2743
2746
caseArg->replaceAllUsesWith (caseLoad);
2744
2747
if (caseArg->getType ().isAddressOnly (*pass.function )) {
2745
2748
// Remap caseArg to the new dummy load which will be deleted during
0 commit comments