@@ -1269,6 +1269,9 @@ class AddressMaterialization {
12691269// /
12701270// / If the operand projects into its use, then the memory was already
12711271// / 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.
12721275void AddressMaterialization::initializeComposingUse (Operand *operand) {
12731276 SILValue def = operand->get ();
12741277 if (def->getType ().isAddressOnly (*pass.function )) {
@@ -1405,15 +1408,15 @@ SILValue AddressMaterialization::materializeStructExtract(
14051408 SILValue srcAddr = pass.getMaterializedAddress (structVal);
14061409 auto *structType = structVal->getType ().getStructOrBoundGenericStruct ();
14071410 auto *varDecl = structType->getStoredProperties ()[fieldIdx];
1408- return B.createStructElementAddr (extractInst-> getLoc (), srcAddr, varDecl,
1411+ return B.createStructElementAddr (pass. genLoc (), srcAddr, varDecl,
14091412 elementValue->getType ().getAddressType ());
14101413}
14111414
14121415// \p tupleInst is a unary instruction whose first operand is a tuple.
14131416SILValue AddressMaterialization::materializeTupleExtract (
14141417 SILInstruction *extractInst, SILValue elementValue, unsigned fieldIdx) {
14151418 SILValue srcAddr = pass.getMaterializedAddress (extractInst->getOperand (0 ));
1416- return B.createTupleElementAddr (extractInst-> getLoc (), srcAddr, fieldIdx,
1419+ return B.createTupleElementAddr (pass. genLoc (), srcAddr, fieldIdx,
14171420 elementValue->getType ().getAddressType ());
14181421}
14191422
@@ -1431,7 +1434,7 @@ AddressMaterialization::materializeProjectionIntoUse(Operand *operand,
14311434 case SILInstructionKind::EnumInst: {
14321435 auto *enumInst = cast<EnumInst>(user);
14331436 SILValue enumAddr = materializeComposingUser (enumInst, intoPhiOperand);
1434- return B.createInitEnumDataAddr (enumInst-> getLoc (), enumAddr,
1437+ return B.createInitEnumDataAddr (pass. genLoc (), enumAddr,
14351438 enumInst->getElement (),
14361439 operand->get ()->getType ().getAddressType ());
14371440 }
@@ -1443,8 +1446,8 @@ AddressMaterialization::materializeProjectionIntoUse(Operand *operand,
14431446 auto opaque = Lowering::AbstractionPattern::getOpaque ();
14441447 auto &concreteTL = pass.function ->getTypeLowering (opaque, canTy);
14451448 return B.createInitExistentialAddr (
1446- initExistentialValue-> getLoc (), containerAddr, canTy,
1447- concreteTL.getLoweredType (), initExistentialValue->getConformances ());
1449+ pass. genLoc (), containerAddr, canTy,
1450+ concreteTL.getLoweredType (), initExistentialValue->getConformances ());
14481451 }
14491452 case SILInstructionKind::StructInst: {
14501453 auto *structInst = cast<StructInst>(user);
@@ -1454,8 +1457,8 @@ AddressMaterialization::materializeProjectionIntoUse(Operand *operand,
14541457
14551458 SILValue structAddr = materializeComposingUser (structInst, intoPhiOperand);
14561459 return B.createStructElementAddr (
1457- structInst-> getLoc (), structAddr, *fieldIter,
1458- operand->get ()->getType ().getAddressType ());
1460+ pass. genLoc (), structAddr, *fieldIter,
1461+ operand->get ()->getType ().getAddressType ());
14591462 }
14601463 case SILInstructionKind::TupleInst: {
14611464 auto *tupleInst = cast<TupleInst>(user);
@@ -1467,7 +1470,7 @@ AddressMaterialization::materializeProjectionIntoUse(Operand *operand,
14671470 return pass.function ->getArguments ()[resultIdx];
14681471 }
14691472 SILValue tupleAddr = materializeComposingUser (tupleInst, intoPhiOperand);
1470- return B.createTupleElementAddr (tupleInst-> getLoc (), tupleAddr,
1473+ return B.createTupleElementAddr (pass. genLoc (), tupleAddr,
14711474 operand->getOperandNumber (),
14721475 operand->get ()->getType ().getAddressType ());
14731476 }
@@ -2739,7 +2742,7 @@ void UseRewriter::visitSwitchEnumInst(SwitchEnumInst * switchEnum) {
27392742 auto *caseAddr =
27402743 caseBuilder.createUncheckedTakeEnumDataAddr (loc, enumAddr, caseDecl);
27412744 auto *caseLoad = caseBuilder.createTrivialLoadOr (
2742- switchEnum-> getLoc () , caseAddr, LoadOwnershipQualifier::Take);
2745+ loc , caseAddr, LoadOwnershipQualifier::Take);
27432746 caseArg->replaceAllUsesWith (caseLoad);
27442747 if (caseArg->getType ().isAddressOnly (*pass.function )) {
27452748 // Remap caseArg to the new dummy load which will be deleted during
0 commit comments