Disentangle moving a machine instr from updating LiveIntervals.
authorLang Hames <lhames@gmail.com>
Wed, 15 Feb 2012 01:23:52 +0000 (01:23 +0000)
committerLang Hames <lhames@gmail.com>
Wed, 15 Feb 2012 01:23:52 +0000 (01:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150552 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveIntervalAnalysis.h
lib/CodeGen/LiveIntervalAnalysis.cpp
lib/CodeGen/MachineScheduler.cpp

index c18c479ce8d2137479c520b6774bc37c7c74a36b..4bc37fd1dafb8b9da9b998a02895f15de990bb8a 100644 (file)
@@ -280,10 +280,11 @@ namespace llvm {
     /// register.
     void addKillFlags();
 
-    /// moveInstr - Move MachineInstr mi to insertPt, updating the live
-    /// intervals of mi's operands to reflect the new position. The insertion
-    /// point can be above or below mi, but must be in the same basic block.
-    void moveInstr(MachineBasicBlock::iterator insertPt, MachineInstr* mi);
+    /// handleMove - call this method to notify LiveIntervals that
+    /// instruction 'mi' has been moved within a basic block. This will update
+    /// the live intervals for all operands of mi. Moves between basic blocks
+    /// are not supported.
+    void handleMove(MachineInstr* mi);
 
     // Register mask functions.
     //
index 30374da18f25a98fa92cb4ceef799cf4391f71c3..d27b8e5fd9f5e135ac1424502623cc3b4fee1f95 100644 (file)
@@ -963,22 +963,17 @@ static void handleMoveUses(const MachineBasicBlock *mbb,
   }
 }
 
-void LiveIntervals::moveInstr(MachineBasicBlock::iterator insertPt,
-                              MachineInstr *mi) {
-  MachineBasicBlock* mbb = mi->getParent();
-  assert((insertPt == mbb->end() || insertPt->getParent() == mbb) &&
-         "Cannot handle moves across basic block boundaries.");
-  assert(&*insertPt != mi && "No-op move requested?");
-  assert(!mi->isBundled() && "Can't handle bundled instructions yet.");
-
-  // Grab the original instruction index.
+void LiveIntervals::handleMove(MachineInstr *mi) {
   SlotIndex origIdx = indexes_->getInstructionIndex(mi);
-
-  // Move the machine instr and obtain its new index.
   indexes_->removeMachineInstrFromMaps(mi);
-  mbb->splice(insertPt, mbb, mi);
   SlotIndex miIdx = indexes_->insertMachineInstrInMaps(mi);
 
+  MachineBasicBlock* mbb = mi->getParent();
+  
+  assert(getMBBFromIndex(origIdx) == mbb &&
+         "Cannot handle moves across basic block boundaries.");
+  assert(!mi->isBundled() && "Can't handle bundled instructions yet.");
+
   // Pick the direction.
   bool movingUp = miIdx < origIdx;
 
index ba87f5a7ab3c58fc04dcaa5fafc5d9622997ff14..da52df9feaeefa2419cf36df83b4024449e45f51 100644 (file)
@@ -229,7 +229,8 @@ void ScheduleTopDownLive::Schedule() {
     if (&*InsertPos == MI)
       ++InsertPos;
     else {
-      Pass->LIS->moveInstr(InsertPos, MI);
+      BB->splice(InsertPos, BB, MI);
+      Pass->LIS->handleMove(MI);
       if (Begin == InsertPos)
         Begin = MI;
     }