https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115606

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note with a modified testcase for C:
```
typedef struct Foo {
  int a, b;
}Foo;

Foo
callee (int i);

Foo 
caller (int i)
{
  return callee (i + 1);
}
```

We get:
  <retval> = callee (_1); [return slot optimization] [tail call]


And then the tail call fails.

Note clang/LLVM also fails to do the tail call here
And with musttail gives an internal compiler error:
```
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++
-gdwarf-4 -g -o /app/output.s -S -target arm-linux-gnueabi
--gcc-toolchain=/opt/compiler-explorer/arm/gcc-12.2.0/arm-unknown-linux-gnueabi
--sysroot=/opt/compiler-explorer/arm/gcc-12.2.0/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot
-fcolor-diagnostics -fno-crash-diagnostics -O2 -g0 <source>
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '<source>'.
4.      Running pass 'ARM Instruction Selection' on function '@_Z6calleri'
 #0 0x00000000037a21e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x37a21e8)
 #1 0x00000000037a0334 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x37a0334)
 #2 0x00000000036e8e33 llvm::CrashRecoveryContext::HandleExit(int)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x36e8e33)
 #3 0x0000000003797a5e llvm::sys::Process::Exit(int, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3797a5e)
 #4 0x0000000000c72976
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xc72976)
 #5 0x00000000036f3433 llvm::report_fatal_error(llvm::Twine const&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x36f3433)
 #6 0x00000000036f3598
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x36f3598)
 #7 0x000000000169cac6
llvm::ARMTargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&,
llvm::SmallVectorImpl<llvm::SDValue>&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x169cac6)
 #8 0x0000000004876419
llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&)
const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4876419)
 #9 0x000000000487824d
llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&,
llvm::BasicBlock const*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x487824d)
#10 0x0000000004898c44 llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase
const&, llvm::SDValue, bool, bool, llvm::BasicBlock const*,
llvm::TargetLowering::PtrAuthInfo const*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4898c44)
#11 0x00000000048af288 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst
const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x48af288)
#12 0x00000000048c3d77 llvm::SelectionDAGBuilder::visit(llvm::Instruction
const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x48c3d77)
#13 0x000000000493c673
llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction,
false, false, void, true, llvm::BasicBlock>, false, true>,
llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction,
false, false, void, true, llvm::BasicBlock>, false, true>, bool&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x493c673)
#14 0x000000000493dd44
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x493dd44)
#15 0x000000000493fbb4
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x493fbb4)
#16 0x000000000162cfe4 (anonymous
namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
ARMISelDAGToDAG.cpp:0:0
#17 0x000000000492f6e1
llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x492f6e1)
#18 0x0000000002bfdbdb
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0)
MachineFunctionPass.cpp:0:0
#19 0x00000000031426f2 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x31426f2)
#20 0x0000000003142871 llvm::FPPassManager::runOnModule(llvm::Module&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3142871)
#21 0x0000000003144520 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3144520)
#22 0x0000000003a3338e clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef,
llvm::Module*, clang::BackendAction,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a3338e)
#23 0x000000000403eb55
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x403eb55)
#24 0x0000000005f5f42c clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5f5f42c)
#25 0x000000000403f395 clang::CodeGenAction::ExecuteAction()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x403f395)
#26 0x00000000042def31 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x42def31)
#27 0x000000000426282b
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x426282b)
#28 0x00000000043c5c63
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x43c5c63)
#29 0x0000000000c746fc cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc746fc)
#30 0x0000000000c6e7fd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&,
llvm::ToolContext const&) driver.cpp:0:0
#31 0x00000000040889d9 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>,
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#32 0x00000000036e8d33
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x36e8d33)
#33 0x0000000004088bf9
clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>,
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#34 0x000000000404e3d7
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&, bool) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x404e3d7)
#35 0x000000000404ed8d
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+++0x404ed8d)
#36 0x0000000004058eec
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4058eec)
#37 0x0000000000c71ba1 clang_main(int, char**, llvm::ToolContext const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xc71ba1)
#38 0x0000000000b4d884 main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xb4d884)
#39 0x000079f1f4e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#40 0x000079f1f4e29e40 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#41 0x0000000000c6e29e _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xc6e29e)
clang++: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
Compiler returned: 70
```

So yes this is invalid.

Reply via email to