Fix a iterator out of bounds error, that triggers rarely.
[oota-llvm.git] / lib / Target / CellSPU / SPUInstrInfo.cpp
index 02cf9bfa735ff74fe0a01c823ef173825ff23c9d..007bc0e02c7ec16b70363e9fbddc5ff09e395a5c 100644 (file)
@@ -290,6 +290,8 @@ static void removeHBR( MachineBasicBlock &MBB) {
     if (I->getOpcode() == SPU::HBRA ||
         I->getOpcode() == SPU::HBR_LABEL){
       I=MBB.erase(I);
+      if (I == MBB.end())
+        break;
     }
   }
 }