Make LiveIntervals::handleMove() bundle aware.
authorLang Hames <lhames@gmail.com>
Wed, 15 Feb 2012 23:21:33 +0000 (23:21 +0000)
committerLang Hames <lhames@gmail.com>
Wed, 15 Feb 2012 23:21:33 +0000 (23:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150630 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 7f29d316ea8592f4c44e22738c275d4d74cc65ac..cd94abae7ec4fbba759614b08fd4b8fd06d451f9 100644 (file)
@@ -234,6 +234,11 @@ public:
   /// if either itself or its following instruction is marked "InsideBundle".
   bool isBundled() const;
 
+  /// getBundleStart - If this instruction is inside a bundle return the
+  /// instruction at the start of the bundle. Otherwise just returns the
+  /// instruction itself.
+  MachineInstr* getBundleStart();
+
   /// getDebugLoc - Returns the debug location id of this MachineInstr.
   ///
   DebugLoc getDebugLoc() const { return debugLoc; }
index a8aa21a96aea6814a508e7c3b648d6f3d840f3c6..0bf47322ba10d2e392317d0120d74d31279a659f 100644 (file)
@@ -963,13 +963,15 @@ static void handleMoveUses(const MachineBasicBlock *mbb,
   }
 }
 
-void LiveIntervals::handleMove(MachineInstr *mi) {
+
+
+void LiveIntervals::handleMove(MachineInstr* mi) {
   SlotIndex origIdx = indexes_->getInstructionIndex(mi);
   indexes_->removeMachineInstrFromMaps(mi);
-  SlotIndex miIdx = indexes_->insertMachineInstrInMaps(mi);
-
+  SlotIndex miIdx = mi->isInsideBundle() ?
+                     indexes_->getInstructionIndex(mi->getBundleStart()) :
+                     indexes_->insertMachineInstrInMaps(mi);
   MachineBasicBlock* mbb = mi->getParent();
-  
   assert(getMBBStartIdx(mbb) <= origIdx && origIdx < getMBBEndIdx(mbb) &&
          "Cannot handle moves across basic block boundaries.");
   assert(!mi->isBundled() && "Can't handle bundled instructions yet.");
index ff32a66b14c2d162c4cc310bf5b715e1095f1cce..52a90960ec592ac87504305f2d10634741c91a4e 100644 (file)
@@ -900,6 +900,16 @@ bool MachineInstr::isBundled() const {
   return nextMI != Parent->instr_end() && nextMI->isInsideBundle();
 }
 
+MachineInstr* MachineInstr::getBundleStart() {
+  if (!isInsideBundle())
+    return this;
+  MachineBasicBlock::reverse_instr_iterator MII(this);
+  --MII;
+  while (MII->isInsideBundle())
+    --MII;
+  return &*MII;
+}
+
 bool MachineInstr::isStackAligningInlineAsm() const {
   if (isInlineAsm()) {
     unsigned ExtraInfo = getOperand(InlineAsm::MIOp_ExtraInfo).getImm();