Skip to content

[RemoveDIs] Support DPValue dbg.declares in MemoryOpRemark #74108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions llvm/lib/Transforms/Utils/MemoryOpRemark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions llvm/test/Transforms/Util/trivial-auto-var-init-call.ll
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions llvm/test/Transforms/Util/trivial-auto-var-init-store.ll
Original file line number Diff line number Diff line change
@@ -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.
Expand Down