[llvm] 300ac0a - [RemoveDIs] Fix removeRedundantDdbgInstrs utils for dbg.declares (#74102)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 12 06:53:31 PST 2023
Author: Orlando Cazalet-Hyams
Date: 2023-12-12T14:53:27Z
New Revision: 300ac0aa85864ddd4ec1b5eb65ae52918434d003
URL: https://github.com/llvm/llvm-project/commit/300ac0aa85864ddd4ec1b5eb65ae52918434d003
DIFF: https://github.com/llvm/llvm-project/commit/300ac0aa85864ddd4ec1b5eb65ae52918434d003.diff
LOG: [RemoveDIs] Fix removeRedundantDdbgInstrs utils for dbg.declares (#74102)
The intrinsic variants of these functions don't do anything to
dbg.declares so the non-instruction variants should ignore them too.
Tested in llvm/test/DebugInfo/duplicate_dbgvalue.ll, which has
`--try-experimental-debuginfo-iterators` added in #73504.
The tests will become "live" once #74090 lands (see for more info).
Added:
Modified:
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index b700edf8ea6c0..8b5a6d6184120 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -387,6 +387,18 @@ static bool DPValuesRemoveRedundantDbgInstrsUsingBackwardScan(BasicBlock *BB) {
SmallDenseSet<DebugVariable> VariableSet;
for (auto &I : reverse(*BB)) {
for (DPValue &DPV : reverse(I.getDbgValueRange())) {
+ // Skip declare-type records, as the debug intrinsic method only works
+ // on dbg.value intrinsics.
+ if (DPV.getType() == DPValue::LocationType::Declare) {
+ // The debug intrinsic method treats dbg.declares are "non-debug"
+ // instructions (i.e., a break in a consecutive range of debug
+ // intrinsics). Emulate that to create identical outputs. See
+ // "Possible improvements" above.
+ // FIXME: Delete the line below.
+ VariableSet.clear();
+ continue;
+ }
+
DebugVariable Key(DPV.getVariable(), DPV.getExpression(),
DPV.getDebugLoc()->getInlinedAt());
auto R = VariableSet.insert(Key);
@@ -478,6 +490,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);
More information about the llvm-commits
mailing list