Skip to content

[StandardInstrumentations] Ensure non-null module pointer when getting display name for IR file #110779

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 1 commit into from
Oct 2, 2024
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
3 changes: 2 additions & 1 deletion llvm/lib/Passes/StandardInstrumentations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@ PrintIRInstrumentation::~PrintIRInstrumentation() {
static SmallString<32> getIRFileDisplayName(Any IR) {
SmallString<32> Result;
raw_svector_ostream ResultStream(Result);
const Module *M = unwrapModule(IR);
const Module *M = unwrapModule(IR, /*Force=*/true);
assert(M && "should have unwrapped module");
uint64_t NameHash = xxh3_64bits(M->getName());
unsigned MaxHashWidth = sizeof(uint64_t) * 2;
write_hex(ResultStream, NameHash, HexPrintStyle::Lower, MaxHashWidth);
Expand Down
14 changes: 14 additions & 0 deletions llvm/test/Other/dump-with-filter.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
;; Make sure we can run -filter-print-funcs with -ir-dump-directory.
; RUN: rm -rf %t/logs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to mkdir %t/logs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's automatically generated by -ir-dump-directory, so I don't think so.

; RUN: opt %s -disable-output -passes='no-op-function' -print-before=no-op-function -print-after=no-op-function \
; RUN: -ir-dump-directory %t/logs -filter-print-funcs=test2
; RUN: ls %t/logs | count 2
; RUN: rm -rf %t/logs

define void @test() {
ret void
}

define void @test2() {
ret void
}
Loading