diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp index 036484c9c1c0c..c960afcf6e973 100644 --- a/llvm/lib/Passes/StandardInstrumentations.cpp +++ b/llvm/lib/Passes/StandardInstrumentations.cpp @@ -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); diff --git a/llvm/test/Other/dump-with-filter.ll b/llvm/test/Other/dump-with-filter.ll new file mode 100644 index 0000000000000..6b6d73112fcc7 --- /dev/null +++ b/llvm/test/Other/dump-with-filter.ll @@ -0,0 +1,14 @@ +;; Make sure we can run -filter-print-funcs with -ir-dump-directory. +; RUN: rm -rf %t/logs +; 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 +}