Skip to content

Commit 7aff4e7

Browse files
committed
[DCE] Add delete handler for phi erasure.
Set CallsChanged when appropriate and increment NumDeletedInsts.
1 parent 499222e commit 7aff4e7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/SILOptimizer/Transforms/DeadCodeElimination.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,17 @@ bool DCE::removeDead() {
728728
endLifetimeOfLiveValue(predOp, insertPt);
729729
}
730730
}
731-
erasePhiArgument(&BB, i, /*cleanupDeadPhiOps=*/true,
732-
InstModCallbacks().onCreateNewInst(
733-
[&](auto *inst) { markInstructionLive(inst); }));
731+
erasePhiArgument(
732+
&BB, i, /*cleanupDeadPhiOps=*/true,
733+
InstModCallbacks()
734+
.onCreateNewInst([&](auto *inst) { markInstructionLive(inst); })
735+
.onDelete([&](auto *inst) {
736+
inst->replaceAllUsesOfAllResultsWithUndef();
737+
if (isa<ApplyInst>(inst))
738+
CallsChanged = true;
739+
++NumDeletedInsts;
740+
inst->eraseFromParent();
741+
}));
734742
Changed = true;
735743
BranchesChanged = true;
736744
}

0 commit comments

Comments
 (0)