Skip to content

Commit f75f12b

Browse files
committed
[DCE] Add delete handler for phi erasure.
Set CallsChanged when appropriate and increment NumDeletedInsts.
1 parent 00116ed commit f75f12b

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
@@ -731,9 +731,17 @@ bool DCE::removeDead() {
731731
endLifetimeOfLiveValue(predOp, insertPt);
732732
}
733733
}
734-
erasePhiArgument(&BB, i, /*cleanupDeadPhiOps=*/true,
735-
InstModCallbacks().onCreateNewInst(
736-
[&](auto *inst) { markInstructionLive(inst); }));
734+
erasePhiArgument(
735+
&BB, i, /*cleanupDeadPhiOps=*/true,
736+
InstModCallbacks()
737+
.onCreateNewInst([&](auto *inst) { markInstructionLive(inst); })
738+
.onDelete([&](auto *inst) {
739+
inst->replaceAllUsesOfAllResultsWithUndef();
740+
if (isa<ApplyInst>(inst))
741+
CallsChanged = true;
742+
++NumDeletedInsts;
743+
inst->eraseFromParent();
744+
}));
737745
Changed = true;
738746
BranchesChanged = true;
739747
}

0 commit comments

Comments
 (0)