Skip to content

Commit 1851e71

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

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
@@ -747,7 +747,8 @@ bool DCE::removeDead() {
747747
// We want to replace dead terminators with unconditional branches to
748748
// the nearest post-dominator that has useful instructions.
749749
if (auto *termInst = dyn_cast<TermInst>(Inst)) {
750-
SILBasicBlock *postDom = nearestUsefulPostDominator(Inst->getParent());
750+
SILBasicBlock *postDom =
751+
nearestUsefulPostDominator(termInst->getParent());
751752
if (!postDom)
752753
continue;
753754

@@ -757,12 +758,12 @@ bool DCE::removeDead() {
757758
}
758759
}
759760
LLVM_DEBUG(llvm::dbgs() << "Replacing branch: ");
760-
LLVM_DEBUG(Inst->dump());
761+
LLVM_DEBUG(termInst->dump());
761762
LLVM_DEBUG(llvm::dbgs()
762763
<< "with jump to: BB" << postDom->getDebugID() << "\n");
763764

764-
replaceBranchWithJump(Inst, postDom);
765-
Inst->eraseFromParent();
765+
replaceBranchWithJump(termInst, postDom);
766+
termInst->eraseFromParent();
766767
BranchesChanged = true;
767768
Changed = true;
768769
continue;

0 commit comments

Comments
 (0)