]> granicus.if.org Git - llvm/commitdiff
[DebugInfo] Pass all values in DebugLocEntry's constructor, NFC
authorDavid Stenberg <david.stenberg@ericsson.com>
Tue, 9 Apr 2019 10:08:26 +0000 (10:08 +0000)
committerDavid Stenberg <david.stenberg@ericsson.com>
Tue, 9 Apr 2019 10:08:26 +0000 (10:08 +0000)
Summary:
With MergeValues() removed, amend DebugLocEntry's constructor so that it
takes multiple values rather than a single, and keep non-fragment values
in OpenRanges, as this allows some cleanup of the code in
buildLocationList().

Reviewers: aprantl, dblaikie, loladiro

Reviewed By: aprantl

Subscribers: hiraditya, llvm-commits

Tags: #debug-info, #llvm

Differential Revision: https://reviews.llvm.org/D59303

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

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

index 5011c84d7f7b9ecda441c77dc47e4208ffad9bba..24eefe4f09236f80d0cd9afecbefa8a39d118fee 100644 (file)
@@ -100,9 +100,13 @@ private:
   SmallVector<Value, 1> Values;
 
 public:
-  DebugLocEntry(const MCSymbol *B, const MCSymbol *E, Value Val)
-      : Begin(B), End(E) {
-    Values.push_back(std::move(Val));
+  /// Create a location list entry for the range [\p Begin, \p End).
+  ///
+  /// \param Vals One or more values describing (parts of) the variable.
+  DebugLocEntry(const MCSymbol *Begin, const MCSymbol *End,
+                ArrayRef<Value> Vals)
+      : Begin(Begin), End(End) {
+    addValues(Vals);
   }
 
   /// Attempt to merge this DebugLocEntry with Next and return
@@ -124,9 +128,10 @@ public:
   void addValues(ArrayRef<DebugLocEntry::Value> Vals) {
     Values.append(Vals.begin(), Vals.end());
     sortUniqueValues();
-    assert(all_of(Values, [](DebugLocEntry::Value V) {
-          return V.isFragment();
-        }) && "value must be a piece");
+    assert((Values.size() == 1 ||
+            all_of(Values,
+                   [](DebugLocEntry::Value V) { return V.isFragment(); })) &&
+           "must either have a single value or multiple pieces");
   }
 
   // Sort the pieces by offset.
index 2b4ba37df1e428cb6229276800d11f83d06872fd..224365e6559796b83fcf3d8dc0c8e479b0f2a970 100644 (file)
@@ -1134,7 +1134,7 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
       continue;
     }
 
-    // If this fragment overlaps with any open ranges, truncate them.
+    // If this debug value overlaps with any open ranges, truncate them.
     const DIExpression *DIExpr = Begin->getDebugExpression();
     auto Last = remove_if(OpenRanges, [&](DebugLocEntry::Value R) {
       return DIExpr->fragmentsOverlap(R.getExpression());
@@ -1156,30 +1156,15 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
     LLVM_DEBUG(dbgs() << "DotDebugLoc: " << *Begin << "\n");
 
     auto Value = getDebugLocValue(Begin);
+    OpenRanges.push_back(Value);
 
     // Omit entries with empty ranges as they do not have any effect in DWARF.
     if (StartLabel == EndLabel) {
-      // If this is a fragment, we must still add the value to the list of
-      // open ranges, since it may describe non-overlapping parts of the
-      // variable.
-      if (DIExpr->isFragment())
-        OpenRanges.push_back(Value);
       LLVM_DEBUG(dbgs() << "Omitting location list entry with empty range.\n");
       continue;
     }
 
-    DebugLocEntry Loc(StartLabel, EndLabel, Value);
-
-    if (DIExpr->isFragment()) {
-      // Add this value to the list of open ranges.
-      OpenRanges.push_back(Value);
-    }
-
-    // Add all values from still valid non-overlapping fragments.
-    if (OpenRanges.size())
-      Loc.addValues(OpenRanges);
-
-    DebugLoc.push_back(std::move(Loc));
+    DebugLoc.emplace_back(StartLabel, EndLabel, OpenRanges);
 
     // Attempt to coalesce the ranges of two otherwise identical
     // DebugLocEntries.
@@ -1962,6 +1947,8 @@ void DebugLocEntry::finalize(const AsmPrinter &AP,
                              DebugLocStream::ListBuilder &List,
                              const DIBasicType *BT,
                              DwarfCompileUnit &TheCU) {
+  assert(!Values.empty() &&
+         "location list entries without values are redundant");
   assert(Begin != End && "unexpected location list entry with empty range");
   DebugLocStream::EntryBuilder Entry(List, Begin, End);
   BufferByteStreamer Streamer = Entry.getStreamer();