[llvm] [RemoveDIs] Support DPValue dbg.declares in MemoryOpRemark (PR #74108)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 1 09:19:49 PST 2023
https://github.com/OCHyams updated https://github.com/llvm/llvm-project/pull/74108
>From eb620fe027155b7b8282aa167f09281671093b36 Mon Sep 17 00:00:00 2001
From: OCHyams <orlando.hyams at sony.com>
Date: Thu, 23 Nov 2023 13:34:44 +0000
Subject: [PATCH 1/2] [RemoveDIs] Support DPValue dbg.declares in
MemoryOpRemark
Depends on #74099, #73500.
---
llvm/lib/Transforms/Utils/MemoryOpRemark.cpp | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp b/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
index 531b0a624dafab6..0219c780b56c966 100644
--- a/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
+++ b/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
@@ -321,8 +321,10 @@ void MemoryOpRemark::visitVariable(const Value *V,
bool FoundDI = false;
// Try to get an llvm.dbg.declare, which has a DILocalVariable giving us the
// real debug info name and size of the variable.
- for (const DbgVariableIntrinsic *DVI :
- FindDbgDeclareUses(const_cast<Value *>(V))) {
+ SmallVector<DbgDeclareInst *> DbgDeclares;
+ SmallVector<DPValue *> DPValues;
+ findDbgDeclares(DbgDeclares, const_cast<Value *>(V), &DPValues);
+ auto FindDI = [&](const auto *DVI) {
if (DILocalVariable *DILV = DVI->getVariable()) {
std::optional<uint64_t> DISize = getSizeInBytes(DILV->getSizeInBits());
VariableInfo Var{DILV->getName(), DISize};
@@ -331,7 +333,10 @@ void MemoryOpRemark::visitVariable(const Value *V,
FoundDI = true;
}
}
- }
+ };
+ for_each(DbgDeclares, FindDI);
+ for_each(DPValues, FindDI);
+
if (FoundDI) {
assert(!Result.empty());
return;
>From a0ae32b1408a020b6a2e2198c44f6c8883605456 Mon Sep 17 00:00:00 2001
From: OCHyams <orlando.hyams at sony.com>
Date: Fri, 1 Dec 2023 17:12:58 +0000
Subject: [PATCH 2/2] ... and the tests ...
---
llvm/test/Transforms/Util/trivial-auto-var-init-call.ll | 1 +
llvm/test/Transforms/Util/trivial-auto-var-init-store.ll | 1 +
2 files changed, 2 insertions(+)
diff --git a/llvm/test/Transforms/Util/trivial-auto-var-init-call.ll b/llvm/test/Transforms/Util/trivial-auto-var-init-call.ll
index f34aa3e9f6799e8..c12648a6b3d81e9 100644
--- a/llvm/test/Transforms/Util/trivial-auto-var-init-call.ll
+++ b/llvm/test/Transforms/Util/trivial-auto-var-init-call.ll
@@ -1,4 +1,5 @@
; RUN: opt -passes=annotation-remarks -o /dev/null -S -pass-remarks-output=%t.opt.yaml %s -pass-remarks-missed=annotation-remarks 2>&1 | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -passes=annotation-remarks -o /dev/null -S -pass-remarks-output=%t.opt.yaml %s -pass-remarks-missed=annotation-remarks 2>&1 | FileCheck %s
; RUN: cat %t.opt.yaml | FileCheck -check-prefix=YAML %s
; Emit remarks for memcpy, memmove, memset, bzero.
diff --git a/llvm/test/Transforms/Util/trivial-auto-var-init-store.ll b/llvm/test/Transforms/Util/trivial-auto-var-init-store.ll
index d3355efe2efcd89..2a7eb638edf6bc9 100644
--- a/llvm/test/Transforms/Util/trivial-auto-var-init-store.ll
+++ b/llvm/test/Transforms/Util/trivial-auto-var-init-store.ll
@@ -1,4 +1,5 @@
; RUN: opt -passes=annotation-remarks -o /dev/null -S -pass-remarks-output=%t.opt.yaml %s -pass-remarks-missed=annotation-remarks 2>&1 | FileCheck %s
+; RUN: opt --try-experimental-debuginfo-iterators -passes=annotation-remarks -o /dev/null -S -pass-remarks-output=%t.opt.yaml %s -pass-remarks-missed=annotation-remarks 2>&1 | FileCheck %s
; RUN: cat %t.opt.yaml | FileCheck -check-prefix=YAML %s
; Emit a remark that reports a store.
More information about the llvm-commits
mailing list