make sure ScheduleDAGInstrs::EmitSchedule does not crash when the first instruction...
authorHal Finkel <hfinkel@anl.gov>
Fri, 2 Dec 2011 04:58:07 +0000 (04:58 +0000)
committerHal Finkel <hfinkel@anl.gov>
Fri, 2 Dec 2011 04:58:07 +0000 (04:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145677 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/ScheduleDAGInstrs.cpp

index 34b8ab0b47f25341bb860b44b71b0c740680067c..5408cdf1ad5745969843540271a2e77e7369936d 100644 (file)
@@ -677,12 +677,12 @@ MachineBasicBlock *ScheduleDAGInstrs::EmitSchedule() {
     else
       // Null SUnit* is a noop.
       EmitNoop();
-  }
 
-  // Update the Begin iterator, as the first instruction in the block
-  // may have been scheduled later.
-  if (!Sequence.empty())
-    Begin = Sequence[0]->getInstr();
+    // Update the Begin iterator, as the first instruction in the block
+    // may have been scheduled later.
+    if (i == 0)
+      Begin = prior(InsertPos);
+  }
 
   // Reinsert any remaining debug_values.
   for (std::vector<std::pair<MachineInstr *, MachineInstr *> >::iterator