summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineBlockPlacement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBlockPlacement.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index 2f4060acbd7..3fd72b99089 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -2789,9 +2789,10 @@ void MachineBlockPlacement::optimizeBranches() {
ChainBB->removeSuccessor(TBB);
// Update the CFG.
- for (MachineBasicBlock::pred_iterator PI = TBB->pred_begin(),
- PE = TBB->pred_end(); PI != PE; ++PI)
- (*PI)->ReplaceUsesOfBlockWith(TBB, ChainBB);
+ while (!TBB->pred_empty()) {
+ MachineBasicBlock *Pred = *(TBB->pred_end()-1);
+ Pred->ReplaceUsesOfBlockWith(TBB, ChainBB);
+ }
for (MachineBasicBlock *Succ : TBB->successors())
ChainBB->addSuccessor(Succ, MBPI->getEdgeProbability(TBB, Succ));
OpenPOWER on IntegriCloud