Another bug fix for empty MBB's
[oota-llvm.git] / lib / CodeGen / RegAllocLocal.cpp
index 23063461d70505a3115cf9255c992b28e1673a08..38e00733602c46c7469baac083c8036bf7f18e38 100644 (file)
@@ -653,7 +653,7 @@ void RA::AllocateBasicBlock(MachineBasicBlock &MBB) {
   const TargetInstrInfo &TII = TM->getInstrInfo();
   MI = MBB.end();
   while (MI != MBB.begin() && TII.isTerminatorInstr((--MI)->getOpcode()));
-  ++MI;
+  if (MI != MBB.end()) ++MI;
 
   // Spill all physical registers holding virtual registers now.
   for (unsigned i = 0, e = RegInfo->getNumRegs(); i != e; ++i)