[llvm] [DebugInfo][RemoveDIs] Implement redundant elimination for DPValues (PR #72284)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 06:57:55 PST 2023


================
@@ -382,7 +382,38 @@ bool llvm::MergeBlockSuccessorsIntoGivenBlocks(
 /// - Check fully overlapping fragments and not only identical fragments.
 /// - Support dbg.declare. dbg.label, and possibly other meta instructions being
 ///   part of the sequence of consecutive instructions.
+static bool DPValuesRemoveRedundantDbgInstrsUsingBackwardScan(BasicBlock *BB) {
+  SmallVector<DPValue *, 8> ToBeRemoved;
+  SmallDenseSet<DebugVariable> VariableSet;
+  for (auto &I : reverse(*BB)) {
+    for (DPValue &DPV : reverse(I.getDbgValueRange())) {
+      DebugVariable Key(DPV.getVariable(),
+                        DPV.getExpression(),
+                        DPV.getDebugLoc()->getInlinedAt());
+      auto R = VariableSet.insert(Key);
+      // If the same variable fragment is described more than once it is enough
+      // to keep the last one (i.e. the first found since we for reverse
+      // iteration).
+      if (!R.second)
----------------
OCHyams wrote:

`// FIXME: Add assignment-tracking support (see removeRedundantDbgInstrsUsingBackwardScan).`?

(maybe not worth the note if it's not been done everywhere)

https://github.com/llvm/llvm-project/pull/72284


More information about the llvm-commits mailing list