aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorOrlando Cazalet-Hyams <orlando.hyams@sony.com>2023-12-12 15:25:08 +0000
committerGitHub <noreply@github.com>2023-12-12 15:25:08 +0000
commit6d46337e13f943e331ae4c048e2456347fc83174 (patch)
tree6f0893bff37168c928dcb6e8a5a5b81707c5e104 /llvm/lib/Transforms/Utils/Local.cpp
parent105adf2cd9588b4839fbdc7287bb76a962fdb8ca (diff)
downloadllvm-6d46337e13f943e331ae4c048e2456347fc83174.zip
llvm-6d46337e13f943e331ae4c048e2456347fc83174.tar.gz
llvm-6d46337e13f943e331ae4c048e2456347fc83174.tar.bz2
[RemoveDIs] Handle DPValues in replaceDbgDeclare (#73507)
The tests will become "live" once #74090 lands (see for more info).
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 63dcb64..19b787c 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -2131,19 +2131,22 @@ bool llvm::replaceDbgDeclare(Value *Address, Value *NewAddress,
DIBuilder &Builder, uint8_t DIExprFlags,
int Offset) {
SmallVector<DbgDeclareInst *, 1> DbgDeclares;
- findDbgDeclares(DbgDeclares, Address);
- for (DbgVariableIntrinsic *DII : DbgDeclares) {
- const DebugLoc &Loc = DII->getDebugLoc();
+ SmallVector<DPValue *, 1> DPValues;
+ findDbgDeclares(DbgDeclares, Address, &DPValues);
+
+ auto ReplaceOne = [&](auto *DII) {
auto *DIVar = DII->getVariable();
auto *DIExpr = DII->getExpression();
assert(DIVar && "Missing variable");
DIExpr = DIExpression::prepend(DIExpr, DIExprFlags, Offset);
- // Insert llvm.dbg.declare immediately before DII, and remove old
- // llvm.dbg.declare.
- Builder.insertDeclare(NewAddress, DIVar, DIExpr, Loc, DII);
- DII->eraseFromParent();
- }
- return !DbgDeclares.empty();
+ DII->setExpression(DIExpr);
+ DII->replaceVariableLocationOp(Address, NewAddress);
+ };
+
+ for_each(DbgDeclares, ReplaceOne);
+ for_each(DPValues, ReplaceOne);
+
+ return !DbgDeclares.empty() || !DPValues.empty();
}
static void updateOneDbgValueForAlloca(const DebugLoc &Loc,