Instructions inside a bundle have the same number as the bundle itself.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 28 Feb 2012 23:52:31 +0000 (23:52 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 28 Feb 2012 23:52:31 +0000 (23:52 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151672 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SlotIndexes.h

index 05daddbcffba9bc4301aace6deff40501d472e22..6c09526b59d20ab8e955b33fe08a125913dab9bd 100644 (file)
@@ -493,8 +493,12 @@ namespace llvm {
     }
 
     /// 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;
     }