diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 7f29d316ea8..cd94abae7ec 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -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; } diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index a8aa21a96ae..0bf47322ba1 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -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."); diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index ff32a66b14c..52a90960ec5 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -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();