DebugInfo: Correct comment & re-format a nearby loop
[oota-llvm.git] / lib / CodeGen / SlotIndexes.cpp
index b4e562e45b27c8d831e4f30f5e819bf27b6b63f6..20049a89d15d8e8d9493198ac60bd81512f11ce4 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)
@@ -199,7 +208,7 @@ void SlotIndexes::repairIndexesInRange(MachineBasicBlock *MBB,
   for (MachineBasicBlock::iterator I = End; I != Begin;) {
     --I;
     MachineInstr *MI = I;
-    if (mi2iMap.find(MI) == mi2iMap.end())
+    if (!MI->isDebugValue() && mi2iMap.find(MI) == mi2iMap.end())
       insertMachineInstrInMaps(MI);
   }
 }