Skip to content

Commit 0d9ff64

Browse files
authored
Merge pull request #6695 from bob-wilson/mem2reg-assert-fix
Fix an assertion failure in SILMem2Reg.
2 parents 8289a19 + f22f05f commit 0d9ff64

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,15 @@ void MemoryToRegisters::removeSingleBlockAllocation(AllocStackInst *ASI) {
505505
break;
506506
}
507507
}
508+
509+
// Remove dead address instructions that may be uses of the allocation.
510+
while (Inst->use_empty() && (isa<StructElementAddrInst>(Inst) ||
511+
isa<TupleElementAddrInst>(Inst))) {
512+
SILValue Next = Inst->getOperand(0);
513+
Inst->eraseFromParent();
514+
NumInstRemoved++;
515+
Inst = cast<SILInstruction>(Next);
516+
}
508517
}
509518
}
510519

0 commit comments

Comments
 (0)