Skip to content

[opt] crash for ctx-prof-flatten-prethinlink pass without GUID metadata #194185

Description

@pektezol

Sample IR:
$ cat test.ir

define void @test() {
  ret void
}

Crashes on opt if assign-guid pass is missing, for any IR input.
The pass should fail gracefully, possibly with reportFatalUsageError(), rather than asserting.

$ opt --mtriple=x86_64-unknown-linux-gnu --passes=ctx-prof-flatten-prethinlink -S test.ir
opt: llvm-project/llvm/lib/Analysis/CtxProfAnalysis.cpp:444: static llvm::GlobalValue::GUID llvm::AssignGUIDPass::getGUID(const llvm::Function&): Assertion `MD && "guid not found for defined function"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: opt --mtriple=x86_64-unknown-linux-gnu --passes=ctx-prof-flatten-prethinlink -S test.ir
1.	Running pass "ctx-prof-flatten" on module "test.ir"
 #0 0x00007f706ce39d62 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvm-project/build/bin/../lib/libLLVMSupport.so.23.0git+0x239d62)
 #1 0x00007f706ce369bf llvm::sys::RunSignalHandlers() (llvm-project/build/bin/../lib/libLLVMSupport.so.23.0git+0x2369bf)
 #2 0x00007f706ce36b0c SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f706c845330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #4 0x00007f706c89eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
 #5 0x00007f706c84527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #6 0x00007f706c8288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #7 0x00007f706c82881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #8 0x00007f706c83b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
 #9 0x00007f70629baa97 llvm::AssignGUIDPass::getGUID(llvm::Function const&) (llvm-project/build/bin/../lib/../lib/libLLVMAnalysis.so.23.0git+0x1baa97)
#10 0x00007f7060f3f4ff llvm::PGOCtxProfFlatteningPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-project/build/bin/../lib/../lib/../lib/libLLVMInstrumentation.so.23.0git+0x13f4ff)
#11 0x00007f70656e9ad5 llvm::detail::PassModel<llvm::Module, llvm::PGOCtxProfFlatteningPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-project/build/bin/../lib/../lib/libLLVMPasses.so.23.0git+0xe9ad5)
#12 0x00007f70625159d7 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-project/build/bin/../lib/../lib/libLLVMCore.so.23.0git+0x3159d7)
#13 0x00007f706d0ef129 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (llvm-project/build/bin/../lib/libLLVMOptDriver.so.23.0git+0x2e129)
#14 0x00007f706d0fa717 optMain (llvm-project/build/bin/../lib/libLLVMOptDriver.so.23.0git+0x39717)
#15 0x00007f706c82a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#16 0x00007f706c82a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#17 0x000059c76bd6e095 _start (llvm-project/build/bin/opt+0x1095)

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]generated by fuzzerllvm:analysisIncludes value tracking, cost tables and constant folding

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions