Guard against de-referencing MBB.end().
authorEvan Cheng <evan.cheng@apple.com>
Tue, 22 Feb 2011 07:07:59 +0000 (07:07 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 22 Feb 2011 07:07:59 +0000 (07:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126192 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/Thumb2InstrInfo.cpp

index 836c1baffd40852033edfe039036813b5485bc9a..9b1073be3c8e42b6d23829012f4208bca09aa690 100644 (file)
@@ -95,8 +95,11 @@ Thumb2InstrInfo::ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail,
 bool
 Thumb2InstrInfo::isLegalToSplitMBBAt(MachineBasicBlock &MBB,
                                      MachineBasicBlock::iterator MBBI) const {
-  while (MBBI->isDebugValue())
+  while (MBBI->isDebugValue()) {
     ++MBBI;
+    if (MBBI == MBB.end())
+      return false;
+  }
 
   unsigned PredReg = 0;
   return llvm::getITInstrPredicate(MBBI, PredReg) == ARMCC::AL;