DeadCodeElimination: don't remove end_lifetime instructions with address operands

DCE cannot reason about values in memory.

Fixes a memory lifetime verification error
rdar://139779406
This commit is contained in:
Erik Eckstein
2024-11-13 12:04:03 +01:00
parent cb6e3db847
commit 64698ca6bb
2 changed files with 26 additions and 1 deletions

View File

@@ -317,6 +317,11 @@ void DCE::markLive() {
break;
}
case SILInstructionKind::EndLifetimeInst: {
if (I.getOperand(0)->getType().isAddress()) {
// DCE cannot reason about values in memory.
markInstructionLive(&I);
break;
}
// The instruction is live only if it's operand value is also live
addReverseDependency(I.getOperand(0), &I);
break;