[llvm-commits] [llvm] r151672 - /llvm/trunk/include/llvm/CodeGen/SlotIndexes.h

Jakob Stoklund Olesen stoklund at 2pi.dk
Tue Feb 28 15:52:31 PST 2012


Author: stoklund
Date: Tue Feb 28 17:52:31 2012
New Revision: 151672

URL: http://llvm.org/viewvc/llvm-project?rev=151672&view=rev
Log:
Instructions inside a bundle have the same number as the bundle itself.

SlotIndexes are not assigned to instructions inside bundles, but it is
still valid to look up the index of those instructions.

The reverse getInstructionFromIndex() will return the first instruction
in the bundle.

Modified:
    llvm/trunk/include/llvm/CodeGen/SlotIndexes.h

Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=151672&r1=151671&r2=151672&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Tue Feb 28 17:52:31 2012
@@ -493,8 +493,12 @@
     }
 
     /// Returns the base index for the given instruction.
-    SlotIndex getInstructionIndex(const MachineInstr *instr) const {
-      Mi2IndexMap::const_iterator itr = mi2iMap.find(instr);
+    SlotIndex getInstructionIndex(const MachineInstr *MI) const {
+      // Instructions inside a bundle have the same number as the bundle itself.
+      MachineBasicBlock::const_instr_iterator I = MI;
+      while (I->isInsideBundle())
+        --I;
+      Mi2IndexMap::const_iterator itr = mi2iMap.find(I);
       assert(itr != mi2iMap.end() && "Instruction not found in maps.");
       return itr->second;
     }





More information about the llvm-commits mailing list