llvm / llvm/llvm-project

[opt] -passes="place-safepoints" causes Assertion `F && "gc.safepoint_poll function is missing"'

Open
#191,975 7 comments 0 reactions 0 assignees View on GitHub
confirmed crash-on-valid generated by fuzzer good first issue llvm:transforms regression:14
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer: https://godbolt.org/z/3PKT68hfb

```
opt: /root/llvm-project/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp:632: void InsertSafepointPoll(llvm::BasicBlock::iterator, std::vector&, const llvm::TargetLibraryInfo&): Assertion `F && "gc.safepoint_poll function is missing"' 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/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=cgscc(function(place-safepoints))
1. Running pass "cgscc(function(place-safepoints))" on module ""
2. Running pass "place-safepoints" on function "test_libcall"
#0 0x0000000005c4f168 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5c4f168)
#1 0x0000000005c4bf94 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5c4bf94)
#2 0x0000000005c4c10a SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007b3682842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007b36828969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007b3682842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007b36828287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007b368282871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007b3682839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000004a2f742 llvm::PlaceSafepointsPass::runImpl(llvm::Function&, llvm::TargetLibraryInfo const&) (.part.0) PlaceSafepoints.cpp:0:0
#10 0x0000000004a2f9f2 llvm::PlaceSafepointsPass::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4a2f9f2)
#11 0x00000000031c743e llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x31c743e)
#12 0x00000000059b0706 llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x59b0706)
#13 0x0000000000f26b6e llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xf26b6e)
#14 0x0000000004fb40a3 llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fb40a3)
#15 0x0000000000f2590e llvm::detail::PassModel, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xf2590e)
#16 0x0000000004facaae llvm::PassManager, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4facaae)
#17 0x00000000031c690e llvm::detail::PassModel, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x31c690e)
#18 0x0000000004fae0a9 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fae0a9)
#19 0x0000000000f258ee llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xf258ee)
#20 0x00000000059b2266 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x59b2266)
#21 0x000000000096f03a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef, llvm::ArrayRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96f03a)
#22 0x00000000009630df optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9630df)
#23 0x00007b3682829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#24 0x00007b3682829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#25 0x00000000009585c5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9585c5)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```

Generated by fuzzer.

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with the linked Compiler Explorer case using opt and the cgscc(function(place-safepoints)) pipeline, then inspect llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp around the assertion. Trace why gc.safepoint_poll is absent and add regression coverage for the reproducer; done means the pipeline no longer aborts and the failure is tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.