Index: include/llvm/CodeGen/SlotIndexes.h =================================================================== --- include/llvm/CodeGen/SlotIndexes.h +++ include/llvm/CodeGen/SlotIndexes.h @@ -122,10 +122,6 @@ return lie.getPointer(); } - unsigned getIndex() const { - return listEntry()->getIndex() | getSlot(); - } - /// Returns the slot for this SlotIndex. Slot getSlot() const { return static_cast(lie.getInt()); @@ -147,6 +143,10 @@ "Attempt to construct index with 0 pointer."); } + unsigned getIndex() const { + return listEntry()->getIndex() | getSlot(); + } + /// Returns true if this is a valid index. Invalid indices do /// not point into an index table, and cannot be compared. bool isValid() const { Index: lib/CodeGen/LiveDebugVariables.cpp =================================================================== --- lib/CodeGen/LiveDebugVariables.cpp +++ lib/CodeGen/LiveDebugVariables.cpp @@ -164,7 +164,7 @@ /// Set of interval start indexes that have been trimmed to the /// lexical scope. - SmallSet trimmedDefs; + SmallDenseMap trimmedDefs; /// insertDebugValue - Insert a DBG_VALUE into MBB at Idx for LocNo. void insertDebugValue(MachineBasicBlock *MBB, SlotIndex StartIdx, @@ -812,10 +812,10 @@ return; if (I.start() < RStart) { + // Remember that this interval was trimmed. + trimmedDefs.insert({RStart.getIndex(), I.start()}); // Interval start overlaps range - trim to the scope range. I.setStartUnchecked(RStart); - // Remember that this interval was trimmed. - trimmedDefs.insert(RStart); } // The end of a lexical scope range is the last instruction in the @@ -1210,8 +1210,9 @@ // If the interval start was trimmed to the lexical scope insert the // DBG_VALUE at the previous index (otherwise it appears after the // first instruction in the range). - if (trimmedDefs.count(Start)) - Start = Start.getPrevIndex(); + auto trimmedDef = trimmedDefs.find(Start.getIndex()); + if (trimmedDef != trimmedDefs.end()) + Start = trimmedDef->second; DEBUG(dbgs() << "\t[" << Start << ';' << Stop << "):" << Loc.locNo()); MachineFunction::iterator MBB = LIS.getMBBFromIndex(Start)->getIterator();