diff options
author | Orlando Cazalet-Hyams <orlando.hyams@sony.com> | 2023-12-12 14:53:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-12 14:53:27 +0000 |
commit | 300ac0aa85864ddd4ec1b5eb65ae52918434d003 (patch) | |
tree | d85cabb3f0daa53cc60a86e4ba88c3f2139759e8 | |
parent | 5457fab15cd210cd7d89278bea173dc5d0261d3b (diff) | |
download | llvm-300ac0aa85864ddd4ec1b5eb65ae52918434d003.zip llvm-300ac0aa85864ddd4ec1b5eb65ae52918434d003.tar.gz llvm-300ac0aa85864ddd4ec1b5eb65ae52918434d003.tar.bz2 |
[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).
-rw-r--r-- | llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp index b700edf..8b5a6d6 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); |