]> granicus.if.org Git - llvm/commitdiff
[DebugInfo] Remove redundant DebugLocEntry::MergeValues() function, NFC
authorDavid Stenberg <david.stenberg@ericsson.com>
Tue, 9 Apr 2019 07:46:09 +0000 (07:46 +0000)
committerDavid Stenberg <david.stenberg@ericsson.com>
Tue, 9 Apr 2019 07:46:09 +0000 (07:46 +0000)
Summary:
The MergeValues() function would try to merge two entries if they shared
the same beginning label. Having the same beginning label means that the
former entry's range would be empty; however, after D55919 we no longer
create entries for empty ranges, so we can no longer land in a situation
where that check in MergeValues would succeed. Instead, the "merging" is
done by keeping the live values from the preceding empty ranges in
OpenRanges, and adding them to the first non-empty range.

Reviewers: aprantl, dblaikie, loladiro

Reviewed By: aprantl

Subscribers: llvm-commits

Tags: #debug-info, #llvm

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

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

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

index 256a41be2373d3ebab918ebd899eb6ba27d07f91..5011c84d7f7b9ecda441c77dc47e4208ffad9bba 100644 (file)
@@ -105,12 +105,6 @@ public:
     Values.push_back(std::move(Val));
   }
 
-  /// If this and Next are describing different pieces of the same
-  /// variable, merge them by appending Next's values to the current
-  /// list of values.
-  /// Return true if the merge was successful.
-  bool MergeValues(const DebugLocEntry &Next);
-
   /// Attempt to merge this DebugLocEntry with Next and return
   /// true if the merge was successful. Entries can be merged if they
   /// share the same Loc/Constant and if Next immediately follows this
index 0e0a5b24864763eec1d701ad1cac7d53f3ce7812..2b4ba37df1e428cb6229276800d11f83d06872fd 100644 (file)
@@ -1094,42 +1094,6 @@ static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) {
   llvm_unreachable("Unexpected 4-operand DBG_VALUE instruction!");
 }
 
-/// If this and Next are describing different fragments of the same
-/// variable, merge them by appending Next's values to the current
-/// list of values.
-/// Return true if the merge was successful.
-bool DebugLocEntry::MergeValues(const DebugLocEntry &Next) {
-  if (Begin == Next.Begin) {
-    auto *FirstExpr = cast<DIExpression>(Values[0].Expression);
-    auto *FirstNextExpr = cast<DIExpression>(Next.Values[0].Expression);
-    if (!FirstExpr->isFragment() || !FirstNextExpr->isFragment())
-      return false;
-
-    // We can only merge entries if none of the fragments overlap any others.
-    // In doing so, we can take advantage of the fact that both lists are
-    // sorted.
-    for (unsigned i = 0, j = 0; i < Values.size(); ++i) {
-      for (; j < Next.Values.size(); ++j) {
-        int res = cast<DIExpression>(Values[i].Expression)->fragmentCmp(
-            cast<DIExpression>(Next.Values[j].Expression));
-        if (res == 0) // The two expressions overlap, we can't merge.
-          return false;
-        // Values[i] is entirely before Next.Values[j],
-        // so go back to the next entry of Values.
-        else if (res == -1)
-          break;
-        // Next.Values[j] is entirely before Values[i], so go on to the
-        // next entry of Next.Values.
-      }
-    }
-
-    addValues(Next.Values);
-    End = Next.End;
-    return true;
-  }
-  return false;
-}
-
 /// Build the location list for all DBG_VALUEs in the function that
 /// describe the same variable.  If the ranges of several independent
 /// fragments of the same variable overlap partially, split them up and
@@ -1205,27 +1169,17 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
     }
 
     DebugLocEntry Loc(StartLabel, EndLabel, Value);
-    bool couldMerge = false;
 
-    // If this is a fragment, it may belong to the current DebugLocEntry.
     if (DIExpr->isFragment()) {
       // Add this value to the list of open ranges.
       OpenRanges.push_back(Value);
-
-      // Attempt to add the fragment to the last entry.
-      if (!DebugLoc.empty())
-        if (DebugLoc.back().MergeValues(Loc))
-          couldMerge = true;
     }
 
-    if (!couldMerge) {
-      // Need to add a new DebugLocEntry. Add all values from still
-      // valid non-overlapping fragments.
-      if (OpenRanges.size())
-        Loc.addValues(OpenRanges);
+    // Add all values from still valid non-overlapping fragments.
+    if (OpenRanges.size())
+      Loc.addValues(OpenRanges);
 
-      DebugLoc.push_back(std::move(Loc));
-    }
+    DebugLoc.push_back(std::move(Loc));
 
     // Attempt to coalesce the ranges of two otherwise identical
     // DebugLocEntries.