struct BranchFolder : public MachineFunctionPass {
static char ID;
- BranchFolder(bool defaultEnableTailMerge) :
+ explicit BranchFolder(bool defaultEnableTailMerge) :
MachineFunctionPass((intptr_t)&ID) {
switch (FlagEnableTailMerge) {
case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break;
unsigned TailLen = 0;
while (I1 != MBB1->begin() && I2 != MBB2->begin()) {
--I1; --I2;
- if (!I1->isIdenticalTo(I2)) {
+ if (!I1->isIdenticalTo(I2) ||
+ // FIXME: This check is dubious. It's used to get around a problem where
+ // people incorrectly expect inline asm directives to remain in the same
+ // relative order. This is untenable because normal compiler
+ // optimizations (like this one) may reorder and/or merge these
+ // directives.
+ I1->getOpcode() == TargetInstrInfo::INLINEASM) {
++I1; ++I2;
break;
}
return true;
else if (p.second->getNumber() > q.second->getNumber())
return false;
- else
+ else {
+ // _GLIBCXX_DEBUG checks strict weak ordering, which involves comparing
+ // an object with itself.
+#ifndef _GLIBCXX_DEBUG
assert(0 && "Predecessor appears twice");
+#endif
+ return(false);
+ }
}
// See if any of the blocks in MergePotentials (which all have a common single
}
// 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);
}
}