Skip to content

Commit fec06e0

Browse files
committed
[Gardening] DCE: Use bound variable in branch.
Rather than reusing the source of the dyn_cast.
1 parent 7542581 commit fec06e0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/SILOptimizer/Transforms/DeadCodeElimination.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,8 @@ bool DCE::removeDead() {
744744
// We want to replace dead terminators with unconditional branches to
745745
// the nearest post-dominator that has useful instructions.
746746
if (auto *termInst = dyn_cast<TermInst>(Inst)) {
747-
SILBasicBlock *postDom = nearestUsefulPostDominator(Inst->getParent());
747+
SILBasicBlock *postDom =
748+
nearestUsefulPostDominator(termInst->getParent());
748749
if (!postDom)
749750
continue;
750751

@@ -754,12 +755,12 @@ bool DCE::removeDead() {
754755
}
755756
}
756757
LLVM_DEBUG(llvm::dbgs() << "Replacing branch: ");
757-
LLVM_DEBUG(Inst->dump());
758+
LLVM_DEBUG(termInst->dump());
758759
LLVM_DEBUG(llvm::dbgs()
759760
<< "with jump to: BB" << postDom->getDebugID() << "\n");
760761

761-
replaceBranchWithJump(Inst, postDom);
762-
Inst->eraseFromParent();
762+
replaceBranchWithJump(termInst, postDom);
763+
termInst->eraseFromParent();
763764
BranchesChanged = true;
764765
Changed = true;
765766
continue;

0 commit comments

Comments
 (0)