Skip to content

Commit 17e13d4

Browse files
committed
InstructionDeleter - ignore already-deleted instructions
Handle uses of deleted instructions in which multiple operands become dead in the same invocation.
1 parent f6ba633 commit 17e13d4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/SILOptimizer/Utils/InstructionDeleter.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,12 @@ void InstructionDeleter::deleteWithUses(SILInstruction *inst, bool fixLifetimes,
216216
}
217217
}
218218
// Process the remaining operands. Insert destroys for consuming
219-
// operands. Track newly dead operand values.
219+
// operands. Track newly dead operand values. Instructions with multiple dead
220+
// operands may occur in toDeleteInsts multiple times.
220221
for (auto *inst : toDeleteInsts) {
222+
if (inst->isDeleted())
223+
continue;
224+
221225
for (Operand &operand : inst->getAllOperands()) {
222226
SILValue operandValue = operand.get();
223227
// Check for dead operands, which are dropped above.
@@ -249,6 +253,9 @@ void InstructionDeleter::cleanupDeadInstructions() {
249253
// append to deadInstructions. So we need to iterate until this it is empty.
250254
deadInstructions.clear();
251255
for (SILInstruction *deadInst : currentDeadInsts) {
256+
if (deadInst->isDeleted())
257+
continue;
258+
252259
// deadInst will not have been deleted in the previous iterations,
253260
// because, by definition, deleteInstruction will only delete an earlier
254261
// instruction and its incidental/destroy uses. The former cannot be

0 commit comments

Comments
 (0)