[llvm] [RemoveDIs] Fix removeRedundantDdbgInstrs utils for dbg.declares (PR #74102)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 1 08:35:06 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Orlando Cazalet-Hyams (OCHyams)

<details>
<summary>Changes</summary>

The intrinsic variants of these functions don't do anything to dbg.declares so the non-instruction variants should too.

Tested in llvm/test/DebugInfo/duplicate_dbgvalue.ll, which has `--try-experimental-debuginfo-iterators` added in #<!-- -->73504.



---
Full diff: https://github.com/llvm/llvm-project/pull/74102.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Utils/BasicBlockUtils.cpp (+4) 


``````````diff
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index ccee97025e3c3f9..1c6b4986c03425f 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -387,6 +387,8 @@ static bool DPValuesRemoveRedundantDbgInstrsUsingBackwardScan(BasicBlock *BB) {
   SmallDenseSet<DebugVariable> VariableSet;
   for (auto &I : reverse(*BB)) {
     for (DPValue &DPV : reverse(I.getDbgValueRange())) {
+      if (DPV.getType() == DPValue::LocationType::Declare)
+        continue;
       DebugVariable Key(DPV.getVariable(), DPV.getExpression(),
                         DPV.getDebugLoc()->getInlinedAt());
       auto R = VariableSet.insert(Key);
@@ -478,6 +480,8 @@ static bool DPValuesRemoveRedundantDbgInstrsUsingForwardScan(BasicBlock *BB) {
       VariableMap;
   for (auto &I : *BB) {
     for (DPValue &DPV : I.getDbgValueRange()) {
+      if (DPV.getType() == DPValue::LocationType::Declare)
+        continue;
       DebugVariable Key(DPV.getVariable(), std::nullopt,
                         DPV.getDebugLoc()->getInlinedAt());
       auto VMI = VariableMap.find(Key);

``````````

</details>


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


More information about the llvm-commits mailing list