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

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 07:50:39 PST 2023


================
@@ -440,7 +471,39 @@ static bool removeRedundantDbgInstrsUsingBackwardScan(BasicBlock *BB) {
 ///
 /// Possible improvements:
 /// - Keep track of non-overlapping fragments.
+static bool DPValuesRemoveRedundantDbgInstrsUsingForwardScan(BasicBlock *BB) {
+  SmallVector<DPValue *, 8> ToBeRemoved;
+  DenseMap<DebugVariable, std::pair<SmallVector<Value *, 4>, DIExpression *>>
+      VariableMap;
+  for (auto &I : *BB) {
+    for (DPValue &DPV : I.getDbgValueRange()) {
+      DebugVariable Key(DPV.getVariable(),
+                        std::nullopt,
+                        DPV.getDebugLoc()->getInlinedAt());
----------------
OCHyams wrote:

It's nothing to do with dbg.assigns - it's just a specialised DebugVariable without a FragmentInfo component, to indicate that it refers to the whole variable. The DebugVariable above is created with a std::nullopt FragmentInfo unconditionally, which is essentially the same thing as a DebugVariableAggregate. It was more a matter of "should we update this code while we're there?" as the change is NFC. No is still a fine answer, I just thought it should be clarified.

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


More information about the llvm-commits mailing list