aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/BranchFolding.cpp9
-rw-r--r--lib/CodeGen/MachineBasicBlock.cpp6
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp
index ad7d5fcc33..d0dcc708d0 100644
--- a/lib/CodeGen/BranchFolding.cpp
+++ b/lib/CodeGen/BranchFolding.cpp
@@ -978,17 +978,18 @@ void BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
}
// Iterate through all the predecessors, revectoring each in-turn.
- MachineBasicBlock::pred_iterator PI = MBB->pred_begin();
+ size_t PI = 0;
bool DidChange = false;
bool HasBranchToSelf = false;
- while (PI != MBB->pred_end()) {
- if (*PI == MBB) {
+ while(PI != MBB->pred_size()) {
+ MachineBasicBlock *PMBB = *(MBB->pred_begin() + PI);
+ if (PMBB == MBB) {
// If this block has an uncond branch to itself, leave it.
++PI;
HasBranchToSelf = true;
} else {
DidChange = true;
- (*PI)->ReplaceUsesOfBlockWith(MBB, CurTBB);
+ PMBB->ReplaceUsesOfBlockWith(MBB, CurTBB);
}
}
diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp
index da062b1559..ba428c5bdb 100644
--- a/lib/CodeGen/MachineBasicBlock.cpp
+++ b/lib/CodeGen/MachineBasicBlock.cpp
@@ -176,10 +176,10 @@ void MachineBasicBlock::removeSuccessor(MachineBasicBlock *succ) {
Successors.erase(I);
}
-void MachineBasicBlock::removeSuccessor(succ_iterator I) {
+MachineBasicBlock::succ_iterator MachineBasicBlock::removeSuccessor(succ_iterator I) {
assert(I != Successors.end() && "Not a current successor!");
(*I)->removePredecessor(this);
- Successors.erase(I);
+ return(Successors.erase(I));
}
void MachineBasicBlock::addPredecessor(MachineBasicBlock *pred) {
@@ -273,7 +273,7 @@ bool MachineBasicBlock::CorrectExtraCFGEdges(MachineBasicBlock *DestA,
++SI;
} else {
// Otherwise, this is a superfluous edge, remove it.
- removeSuccessor(SI);
+ SI = removeSuccessor(SI);
MadeChange = true;
}
}