aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/UnreachableBlockElim.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/UnreachableBlockElim.cpp')
-rw-r--r--llvm/lib/CodeGen/UnreachableBlockElim.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/UnreachableBlockElim.cpp b/llvm/lib/CodeGen/UnreachableBlockElim.cpp
index f5dc589a98cb..c9a19948ff2f 100644
--- a/llvm/lib/CodeGen/UnreachableBlockElim.cpp
+++ b/llvm/lib/CodeGen/UnreachableBlockElim.cpp
@@ -114,25 +114,23 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
// Loop over all dead blocks, remembering them and deleting all instructions
// in them.
std::vector<MachineBasicBlock*> DeadBlocks;
- for (MachineFunction::iterator I = F.begin(), E = F.end(); I != E; ++I) {
- MachineBasicBlock *BB = &*I;
-
+ for (MachineBasicBlock &BB : F) {
// Test for deadness.
- if (!Reachable.count(BB)) {
- DeadBlocks.push_back(BB);
+ if (!Reachable.count(&BB)) {
+ DeadBlocks.push_back(&BB);
// Update dominator and loop info.
- if (MLI) MLI->removeBlock(BB);
- if (MDT && MDT->getNode(BB)) MDT->eraseNode(BB);
+ if (MLI) MLI->removeBlock(&BB);
+ if (MDT && MDT->getNode(&BB)) MDT->eraseNode(&BB);
- while (BB->succ_begin() != BB->succ_end()) {
- MachineBasicBlock* succ = *BB->succ_begin();
+ while (BB.succ_begin() != BB.succ_end()) {
+ MachineBasicBlock* succ = *BB.succ_begin();
MachineBasicBlock::iterator start = succ->begin();
while (start != succ->end() && start->isPHI()) {
for (unsigned i = start->getNumOperands() - 1; i >= 2; i-=2)
if (start->getOperand(i).isMBB() &&
- start->getOperand(i).getMBB() == BB) {
+ start->getOperand(i).getMBB() == &BB) {
start->RemoveOperand(i);
start->RemoveOperand(i-1);
}
@@ -140,7 +138,7 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
start++;
}
- BB->removeSuccessor(BB->succ_begin());
+ BB.removeSuccessor(BB.succ_begin());
}
}
}