<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/90194>90194</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            LLVM backend crashes on arm when `musttail` with more than 5 parameters
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          yujincheng08
      </td>
    </tr>
</table>

<pre>
    When using `musttail` on functions with more than 5 parameters, LLVM backend crashes:

<details>

```
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-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics --target=armv7a-linux-android <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 '@_Z3fb5lllll'
 #0 0x000000000394d2d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x394d2d8)
 #1 0x000000000394afbc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x394afbc)
 #2 0x000000000389c976 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x389c976)
 #3 0x0000000003941e1e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3941e1e)
 #4 0x0000000000c4888a LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
 #5 0x00000000038a7353 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38a7353)
 #6 0x00000000038a74b8 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38a74b8)
 #7 0x000000000171954d llvm::ARMTargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&, llvm::SmallVectorImpl<llvm::SDValue>&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x171954d)
 #8 0x0000000004a1f71c llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a1f71c)
 #9 0x0000000004a2afdf llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&, llvm::BasicBlock const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a2afdf)
#10 0x0000000004a469de llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase const&, llvm::SDValue, bool, bool, llvm::BasicBlock const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a469de)
#11 0x0000000004a5b711 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a5b711)
#12 0x0000000004a6f98f llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a6f98f)
#13 0x0000000004af58fd llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true>, false, true>, bool&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4af58fd)
#14 0x0000000004af665c llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4af665c)
#15 0x0000000004af83e7 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#16 0x00000000016bd114 (anonymous namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) ARMISelDAGToDAG.cpp:0:0
#17 0x0000000002d22301 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#18 0x00000000032ebf53 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x32ebf53)
#19 0x00000000032ec191 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x32ec191)
#20 0x00000000032ec9f5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x32ec9f5)
#21 0x0000000003bd818c (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0
#22 0x0000000003bd854e 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-assertions-trunk/bin/clang+++0x3bd854e)
#23 0x0000000004208d4c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4208d4c)
#24 0x00000000062129ec clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62129ec)
#25 0x00000000042080c8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42080c8)
#26 0x0000000004487859 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4487859)
#27 0x0000000004410d2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4410d2e)
#28 0x000000000456b4ae clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x456b4ae)
#29 0x0000000000c4ab4c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4ab4c)
#30 0x0000000000c43dda ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#31 0x000000000424b0e9 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 0x000000000389c8b4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x389c8b4)
#33 0x000000000424b6df 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 0x0000000004211a15 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4211a15)
#35 0x000000000421247d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x421247d)
#36 0x000000000421a205 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x421a205)
#37 0x0000000000c47fe5 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc47fe5)
#38 0x0000000000b2aa14 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb2aa14)
#39 0x0000790ba3429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#40 0x0000790ba3429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#41 0x0000000000c438ce _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc438ce)
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70
```

</details>

Example: https://godbolt.org/z/hYTY71Tbs

However, when compiling to aarch64, it works, see: https://godbolt.org/z/bP7fdPvYT
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl1z46jS_jXKDeWUhGRbvsiF48Q7szWpSSXZfWvfGxeCls0GgQ6gfJxffwokOUJxMtk98dRWndRMYgNqnn66aZoWxBi-lQBn0fQ8ml6ckMbulD57bv7kku5AbuP8pFDs-ez_diBRY7jcomgWV42xlnARzWKkJCobSS1X0qBHbneoUhqQ3RGJpqgmmlRgQZsIr9C3b79foYLQe5AMUU3MDkyULqP4Ior73-mKgZNtovQy6JjF3T__tSSWCARaKx2ly_YD4rKX7tpKwgUwZBWqQZdKV8jJRZQIgUDwikviUDsNSNtquAVUEX0PDO119NNdf7tc3l4i0xQVt4igotkiDbXS1snfWVt7RfA6wustt7umOKWqivBaiIf-z6TW6k-gNsJrbkwDJsJrRCRDXFLRMMcZtKx4LawmFBxrtYZaKwrGAENGNbptdk8SYxTlxAJDupHIUM1re9pCvrWE3iPWVPWe4vg0ihfXWm01qRDR26YCaR1wFOG1qh0yqqqaC9ATeKqF0qBdmyByOyHGgPZmnljdyPsIrwsu--4In0f4HE227JHocpKhyRZNlJNL6tpJb2z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