misched: obvious iterator update fixes for bottom-up.
authorAndrew Trick <atrick@apple.com>
Wed, 21 Mar 2012 04:12:10 +0000 (04:12 +0000)
committerAndrew Trick <atrick@apple.com>
Wed, 21 Mar 2012 04:12:10 +0000 (04:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153160 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineScheduler.cpp

index 9f67d6d0189b68115a23e408483cf49e6292d5f6..57ae6dc02a4d4daf35d190f087323690bee19ec2 100644 (file)
@@ -369,8 +369,12 @@ void ScheduleDAGMI::releasePredecessors(SUnit *SU) {
 
 void ScheduleDAGMI::moveInstruction(MachineInstr *MI,
                                     MachineBasicBlock::iterator InsertPos) {
+  // Fix RegionBegin if the first instruction moves down.
+  if (&*RegionBegin == MI)
+    RegionBegin = llvm::next(RegionBegin);
   BB->splice(InsertPos, BB, MI);
   LIS->handleMove(MI);
+  // Fix RegionBegin if another instruction moves above the first instruction.
   if (RegionBegin == InsertPos)
     RegionBegin = MI;
 }
@@ -440,6 +444,8 @@ void ScheduleDAGMI::schedule() {
       if (&*llvm::prior(CurrentBottom) == MI)
         --CurrentBottom;
       else {
+        if (&*CurrentTop == MI)
+          CurrentTop = llvm::next(CurrentTop);
         moveInstruction(MI, CurrentBottom);
         CurrentBottom = MI;
       }