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
PowerPC: fatal error: error in backend: failed to perform tail call elimination on a call site marked musttail #56679
Comments
Could you please try |
@llvm/issue-subscribers-backend-powerpc |
godbolt.org, when compiling with power64le clang (trunk), says: fatal error: error in backend: failed to perform tail call elimination on a call site marked musttail
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o /app/output.s -S -target powerpc64le -fcolor-diagnostics -fno-crash-diagnostics -std=gnu++20 <source>
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '<source>'.
4. Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@_Z16watcherGeneratorIM10QWebSocketFvibEEN5QCoro14AsyncGeneratorIN21unwrapped_signal_argsIN11signal_argsIT_E5typesEE4typeEEEPS0_S7_.resume'
#0 0x00005655011c5904 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x00005655011c372c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x38af72c)
#2 0x00005655011027b8 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x37ee7b8)
#3 0x00005655011bb832 llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x38a7832)
#4 0x00005654feb280cf (/opt/compiler-explorer/clang-trunk/bin/clang+++0x12140cf)
#5 0x000056550110904a llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x37f504a)
#6 0x00005655011091de (/opt/compiler-explorer/clang-trunk/bin/clang+++0x37f51de)
#7 0x00005654ff9a2511 llvm::PPCTargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&, llvm::SmallVectorImpl<llvm::SDValue>&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x208e511)
#8 0x00005655021ef5b8 llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x48db5b8)
#9 0x00005655021f11ba llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&, llvm::BasicBlock const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x48dd1ba)
#10 0x00005655022073d9 llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase const&, llvm::SDValue, bool, bool, llvm::BasicBlock const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x48f33d9)
#11 0x000056550221b2b1 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x49072b1)
#12 0x00005655022313e7 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x491d3e7)
#13 0x00005655022a024e llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>, false, true>, bool&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x498c24e)
#14 0x00005655022a26c9 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x498e6c9)
#15 0x00005655022a4118 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#16 0x00005654ff9409d8 (anonymous namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) PPCISelDAGToDAG.cpp:0:0
#17 0x00005655004b75ec llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2ba35ec)
#18 0x00005655009654f0 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x30514f0)
#19 0x0000565500965669 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3051669)
#20 0x0000565500966250 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3052250)
#21 0x000056550156f57a clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c5b57a)
#22 0x00005655023e0218 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4acc218)
#23 0x00005655035aac99 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c96c99)
#24 0x00005655023df815 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4acb815)
#25 0x0000565501ce8c01 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x43d4c01)
#26 0x0000565501c70ac3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x435cac3)
#27 0x0000565501dc723b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44b323b)
#28 0x00005654feb296e4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x12156e4)
#29 0x00005654feb22c8b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#30 0x0000565501adaa99 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#31 0x0000565501102637 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x37ee637)
#32 0x0000565501adb08c clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#33 0x0000565501aa50fe clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x41910fe)
#34 0x0000565501aa5b1d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4191b1d)
#35 0x0000565501ab096c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x419c96c)
#36 0x00005654feb27469 clang_main(int, char**) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x1213469)
#37 0x00007f020924a0b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#38 0x00005654feb2289e _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0x120e89e)
clang-15: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70 |
This issue also exists on powerpc64le A narrow down case:
|
This seems like PPC target will not do tail call optimization for indirect calls. For indirect calls, when returning from the callee, PPC backend needs to insert instructions to restore the TOC after the normal call instruction. If we do tail call optimization to the call instruction on PPC, then no opportunity to restore the TOC for the caller. See llvm-project/llvm/lib/Target/PowerPC/PPCISelLowering.cpp Lines 4872 to 4888 in 57e3fa3
|
I'm not sure if we can relax this restriction. |
Imaging a case like: FILE1:
FILE2:
If we return from For the indirect call case in this issue, it is very hard to conclude that the indirect call |
For tagets which doesn't support llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp Lines 143 to 145 in d0cf7b2
|
OK, that sounds like right thing for PPC part. But PPC indeed supports tail call, we still need to return |
We would not want to turn off tail calls without context as suggested. The only way I see forward would be to do one of the following:
|
FreeBSD 13.1-RELEASE on powerpc / powerpc64 / powerpc64le
LLVM 14.0.6
Build with:
Output:
fatal error: error in backend: failed to perform tail call elimination on a call site marked musttail
The text was updated successfully, but these errors were encountered: