[Gardening] DCE: Use bound variable in branch.

Rather than reusing the source of the dyn_cast.
This commit is contained in:
Nate Chandler
2024-12-19 14:19:11 -08:00
parent 31b6aee3b8
commit 1851e712f8

View File

@@ -747,7 +747,8 @@ bool DCE::removeDead() {
// We want to replace dead terminators with unconditional branches to
// the nearest post-dominator that has useful instructions.
if (auto *termInst = dyn_cast<TermInst>(Inst)) {
SILBasicBlock *postDom = nearestUsefulPostDominator(Inst->getParent());
SILBasicBlock *postDom =
nearestUsefulPostDominator(termInst->getParent());
if (!postDom)
continue;
@@ -757,12 +758,12 @@ bool DCE::removeDead() {
}
}
LLVM_DEBUG(llvm::dbgs() << "Replacing branch: ");
LLVM_DEBUG(Inst->dump());
LLVM_DEBUG(termInst->dump());
LLVM_DEBUG(llvm::dbgs()
<< "with jump to: BB" << postDom->getDebugID() << "\n");
replaceBranchWithJump(Inst, postDom);
Inst->eraseFromParent();
replaceBranchWithJump(termInst, postDom);
termInst->eraseFromParent();
BranchesChanged = true;
Changed = true;
continue;