[llvm] [DebugInfo][RemoveDIs] Instrument loop-deletion for DPValues (PR #73042)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 14:12:32 PST 2023


================
@@ -628,6 +629,24 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE,
                    "Unexpected user in reachable block");
           U.set(Poison);
         }
+
+        // RemoveDIs: do the same as below for DPValues.
+        if (Block->IsNewDbgInfoFormat) {
+          for (DPValue &DPV : llvm::make_early_inc_range(I.getDbgValueRange())) {
+            auto Key =
+                DeadDebugSet.find(DebugVariable(DPV.getVariable(), DPV.getExpression(), nullptr));
+            if (Key != DeadDebugSet.end())
+              continue;
+            // Unlinks the DPV from it's container, for later insertion.
+            DPV.removeFromParent();
+            DeadDebugSet.insert(DebugVariable(DPV.getVariable(), DPV.getExpression(), nullptr));
+            DeadDPValues.push_back(&DPV);
----------------
OCHyams wrote:

Any reason not to use `if(!DeadDebugSet.insert(...).second) continue;`, as below in the dbg.value loop, instead of using `find` then `insert`?


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


More information about the llvm-commits mailing list