Debug info: Modify DebugLocEntry::addValue to take multiple values so it
authorAdrian Prantl <aprantl@apple.com>
Mon, 11 Aug 2014 21:06:00 +0000 (21:06 +0000)
committerAdrian Prantl <aprantl@apple.com>
Mon, 11 Aug 2014 21:06:00 +0000 (21:06 +0000)
only has to sort/unique values once per batch.

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

lib/CodeGen/AsmPrinter/DebugLocEntry.h
lib/CodeGen/AsmPrinter/DwarfDebug.cpp

index 41735fca3765cd0df29f48885b4ce52f9cd69182..ba05aa711574ed64d1e0d79bd5554b53809804b8 100644 (file)
@@ -114,8 +114,7 @@ public:
       DIVariable NextVar(Next.Values[0].Variable);
       if (Var.getName() == NextVar.getName() &&
           Var.isVariablePiece() && NextVar.isVariablePiece()) {
-        Values.append(Next.Values.begin(), Next.Values.end());
-        sortUniqueValues();
+        addValues(Next.Values);
         End = Next.End;
         return true;
       }
@@ -139,11 +138,12 @@ public:
   const MCSymbol *getBeginSym() const { return Begin; }
   const MCSymbol *getEndSym() const { return End; }
   const ArrayRef<Value> getValues() const { return Values; }
-  void addValue(Value Val) {
-    assert(DIVariable(Val.Variable).isVariablePiece() &&
-           "multi-value DebugLocEntries must be pieces");
-    Values.push_back(Val);
+  void addValues(ArrayRef<DebugLocEntry::Value> Vals) {
+    Values.append(Vals.begin(), Vals.end());
     sortUniqueValues();
+    assert(std::all_of(Values.begin(), Values.end(), [](DebugLocEntry::Value V){
+          return DIVariable(V.Variable).isVariablePiece();
+        }) && "value must be a piece");
   }
 
   // Sort the pieces by offset.
index 57dda88b0021b11a1602cf651f6a045bde5ac0dd..a669077f08b48fad4cc63b9e43d140c023f417b4 100644 (file)
@@ -1288,8 +1288,9 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
     if (!couldMerge) {
       // Need to add a new DebugLocEntry. Add all values from still
       // valid non-overlapping pieces.
-      for (auto Range : OpenRanges)
-        Loc.addValue(Range.second);
+      if (OpenRanges.size())
+        Loc.addValues(OpenRanges);
+
       DebugLoc.push_back(std::move(Loc));
     }