Find anchoring end points for repairIntervalsInRange and repairIndexesInRange
[oota-llvm.git] / lib / CodeGen / SlotIndexes.cpp
index b4e562e45b27c8d831e4f30f5e819bf27b6b63f6..f2937941ee9fc4ae048d100e2debdf1a6d680c26 100644 (file)
@@ -146,6 +146,15 @@ void SlotIndexes::renumberIndexes(IndexList::iterator curItr) {
 void SlotIndexes::repairIndexesInRange(MachineBasicBlock *MBB,
                                        MachineBasicBlock::iterator Begin,
                                        MachineBasicBlock::iterator End) {
+  // FIXME: Is this really necessary? The only caller repairIntervalsForRange()
+  // does the same thing.
+  // Find anchor points, which are at the beginning/end of blocks or at
+  // instructions that already have indexes.
+  while (Begin != MBB->begin() && !hasIndex(Begin))
+    --Begin;
+  while (End != MBB->end() && !hasIndex(End))
+    ++End;
+
   bool includeStart = (Begin == MBB->begin());
   SlotIndex startIdx;
   if (includeStart)