Turns out AnalyzeBranch can modify the mbb being analyzed. This is a nasty
[oota-llvm.git] / lib / Target / Mips / MipsInstrInfo.cpp
index daff538067529ab283bcc46ad9e6525996663f4b..758e9bea5ad5617129e3a987e67f9142273f6805 100644 (file)
@@ -453,7 +453,8 @@ Mips::CondCode Mips::GetOppositeBranchCondition(Mips::CondCode CC)
 bool MipsInstrInfo::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();
@@ -525,7 +526,8 @@ bool MipsInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,
   if ((SecondLastOpc == Mips::J) && (LastOpc == Mips::J)) {
     TBB = SecondLastInst->getOperand(0).getMBB();
     I = LastInst;
-    I->eraseFromParent();
+    if (AllowModify)
+      I->eraseFromParent();
     return false;
   }