File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -473,6 +473,19 @@ class ClosureCleanup {
473473 // / This regular instruction deletion callback checks for any function-type
474474 // / values that may be unused after deleting the given instruction.
475475 void recordDeadFunction (SILInstruction *deletedInst) {
476+ // If it is a debug instruction, return.
477+ // In this function, we look at operands of an instruction to be
478+ // deleted, and add back the defining instruction of the operands to the
479+ // worklist if it has a function type. This works in general when we are
480+ // deleting dead instructions recursively.
481+ // But we also consider, an instruction with only debug uses as dead.
482+ // And with eraseFromParentWithDebugInsts, we will be deleting a dead
483+ // instruction with its debug instructions. So when we are deleting a debug
484+ // instruction, we may have already deleted its operand's defining
485+ // instruction. So it would be incorrect to add back its operand's defining
486+ // instruction.
487+ if (deletedInst->isDebugInstruction ())
488+ return ;
476489 // If the deleted instruction was already recorded as a function producer,
477490 // delete it from the map and record its operands instead.
478491 deadFunctionVals.erase (deletedInst);
You can’t perform that action at this time.
0 commit comments