Fix a bad iterator dereference that Evan uncovered.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 28 Jun 2011 01:18:58 +0000 (01:18 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 28 Jun 2011 01:18:58 +0000 (01:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133978 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SplitKit.cpp

index 18f315ab20df9f9fb3315aed60e8b5e30f59eef5..55b1114b5b2c3b3ca3af83f5351e24124fd35821 100644 (file)
@@ -76,12 +76,14 @@ SlotIndex SplitAnalysis::computeLastSplitPoint(unsigned Num) {
       return LSP.first;
     // There may not be a call instruction (?) in which case we ignore LPad.
     LSP.second = LSP.first;
-    for (MachineBasicBlock::const_iterator I = FirstTerm, E = MBB->begin();
-         I != E; --I)
+    for (MachineBasicBlock::const_iterator I = MBB->end(), E = MBB->begin();
+         I != E;) {
+      --I;
       if (I->getDesc().isCall()) {
         LSP.second = LIS.getInstructionIndex(I);
         break;
       }
+    }
   }
 
   // If CurLI is live into a landing pad successor, move the last split point