[DCE] Destroys of live values are live.

As is done for `end_borrow`s, add a dependency from a `destroy_value`s
to its operand so that it is not eliminated if its operand isn't.
This commit is contained in:
Nate Chandler
2023-04-06 13:33:50 -07:00
parent 5f5692c3ba
commit 38cbc6fde1
2 changed files with 47 additions and 0 deletions

View File

@@ -280,6 +280,8 @@ void DCE::markLive() {
if (phi && (phi->isLexical() || hasPointerEscape(phi))) {
markInstructionLive(&I);
}
// The instruction is live only if it's operand value is also live
addReverseDependency(I.getOperand(0), &I);
break;
}
case SILInstructionKind::EndBorrowInst: {