[llvm] 4fc6048 - [RemoveDIs] Support DPValue dbg.declares in MemoryOpRemark (#74108)

via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 13 04:47:24 PST 2023


Author: Orlando Cazalet-Hyams
Date: 2023-12-13T12:47:20Z
New Revision: 4fc604899f551826fc850a00cce5def0ccafb653

URL: https://github.com/llvm/llvm-project/commit/4fc604899f551826fc850a00cce5def0ccafb653
DIFF: https://github.com/llvm/llvm-project/commit/4fc604899f551826fc850a00cce5def0ccafb653.diff

LOG: [RemoveDIs] Support DPValue dbg.declares in MemoryOpRemark (#74108)

Depends on #74099, #73500.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
    llvm/test/Transforms/Util/trivial-auto-var-init-call.ll
    llvm/test/Transforms/Util/trivial-auto-var-init-store.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp b/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
index 5c3776683d5d6f..47c6bcbaf26ec2 100644
--- a/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
+++ b/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
@@ -322,8 +322,9 @@ void MemoryOpRemark::visitVariable(const Value *V,
   // Try to get an llvm.dbg.declare, which has a DILocalVariable giving us the
   // real debug info name and size of the variable.
   SmallVector<DbgDeclareInst *, 1> DbgDeclares;
-  findDbgDeclares(DbgDeclares, const_cast<Value *>(V));
-  for (const DbgVariableIntrinsic *DVI : DbgDeclares) {
+  SmallVector<DPValue *, 1> 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};
@@ -332,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;

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 f34aa3e9f6799e..c12648a6b3d81e 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 d3355efe2efcd8..2a7eb638edf6bc 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