@@ -549,15 +549,17 @@ SILValue DestroyHoisting::createAddress(unsigned locIdx, SILBuilder &builder) {
549
549
assert (!isa<BeginAccessInst>(loc->representativeValue ) &&
550
550
" only a root location can be a begin_access" );
551
551
552
- SingleValueInstruction *&cachedProj = addressProjections[locIdx];
553
- if (cachedProj)
554
- return cachedProj;
555
-
556
552
if (!domTree)
557
553
domTree = DA->get (function);
554
+
555
+ SILInstruction *ip = &*builder.getInsertionPoint ();
556
+
557
+ SingleValueInstruction *&cachedProj = addressProjections[locIdx];
558
+ if (cachedProj && domTree->properlyDominates (cachedProj, ip))
559
+ return cachedProj;
558
560
559
561
auto *projInst = cast<SingleValueInstruction>(loc->representativeValue );
560
- if (domTree->properlyDominates (projInst, &*builder. getInsertionPoint () )) {
562
+ if (domTree->properlyDominates (projInst, ip )) {
561
563
cachedProj = projInst;
562
564
return projInst;
563
565
}
@@ -580,7 +582,7 @@ SILValue DestroyHoisting::createAddress(unsigned locIdx, SILBuilder &builder) {
580
582
newProj = projBuilder.createTupleElementAddr (TEA->getLoc (), baseAddr,
581
583
TEA->getFieldNo (), TEA->getType ());
582
584
}
583
- assert (domTree->properlyDominates (newProj, &*builder. getInsertionPoint () ) &&
585
+ assert (domTree->properlyDominates (newProj, ip ) &&
584
586
" new projection does not dominate insert point" );
585
587
// We need to remember the new projection instruction because in tailMerging
586
588
// we might call locations.getLocationIdx() on such a new instruction.
0 commit comments