Turns out AnalyzeBranch can modify the mbb being analyzed. This is a nasty
[oota-llvm.git] / lib / Target / CellSPU / SPUInstrInfo.cpp
index 559f095e7a6dc9a2c489692a06c4e42a68ed32d8..ded83247610aff6fe0a9964b1714f90dd6145447 100644 (file)
@@ -524,7 +524,8 @@ SPUInstrInfo::foldMemoryOperandImpl(MachineFunction &MF,
 bool
 SPUInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
                             MachineBasicBlock *&FBB,
-                            SmallVectorImpl<MachineOperand> &Cond) const {
+                            SmallVectorImpl<MachineOperand> &Cond,
+                            bool AllowModify) const {
   // If the block has no terminators, it just falls into the block after it.
   MachineBasicBlock::iterator I = MBB.end();
   if (I == MBB.begin() || !isUnpredicatedTerminator(--I))
@@ -575,7 +576,8 @@ SPUInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
   if (isUncondBranch(SecondLastInst) && isUncondBranch(LastInst)) {
     TBB = SecondLastInst->getOperand(0).getMBB();
     I = LastInst;
-    I->eraseFromParent();
+    if (AllowModify)
+      I->eraseFromParent();
     return false;
   }