/// removeSuccessor - Remove specified successor from the successors list of
/// this MachineBasicBlock. The Predecessors list of succ is automatically
- /// updated.
+ /// updated. Return the iterator to the element after the one removed.
///
- void removeSuccessor(succ_iterator I);
+ succ_iterator removeSuccessor(succ_iterator I);
/// isSuccessor - Return true if the specified MBB is a successor of this
/// block.
}
// 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);
}
}
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) {
++SI;
} else {
// Otherwise, this is a superfluous edge, remove it.
- removeSuccessor(SI);
+ SI = removeSuccessor(SI);
MadeChange = true;
}
}