<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/157028>157028</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64] crash on __attribute__((nvptx_kernel))
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AArch64,
crash
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
Reproducer:
https://godbolt.org/z/8bc9GPo7h
```cpp
__attribute__((nvptx_kernel)) void foo(int *ret) {
*ret = 1;
}
```
Backtrace:
```console
fatal error: error in backend: unsupported calling convention
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 -fno-verbose-asm -S -target aarch64-linux-gnu --gcc-toolchain=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu --sysroot=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '<source>'.
4. Running pass 'IRTranslator' on function '@_Z3fooPi'
#0 0x0000000003c46448 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c46448)
#1 0x0000000003c43e1c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c43e1c)
#2 0x0000000003b94203 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b94203)
#3 0x0000000003c3b66e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c3b66e)
#4 0x0000000000dbf31b LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
#5 0x0000000003b9df73 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b9df73)
#6 0x0000000003b9e176 (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b9e176)
#7 0x0000000000fcd959 llvm::AArch64TargetLowering::CCAssignFnForCall(unsigned int, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0xfcd959)
#8 0x0000000000e531af llvm::AArch64CallLowering::lowerFormalArguments(llvm::MachineIRBuilder&, llvm::Function const&, llvm::ArrayRef<llvm::ArrayRef<llvm::Register>>, llvm::FunctionLoweringInfo&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0xe531af)
#9 0x0000000004ed6d80 llvm::IRTranslator::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4ed6d80)
#10 0x00000000030540ad llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x30540ad)
#11 0x00000000035abab2 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35abab2)
#12 0x00000000035abd41 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35abd41)
#13 0x00000000035ad617 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35ad617)
#14 0x0000000003ee4e5d clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, 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+++0x3ee4e5d)
#15 0x000000000450d90c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x450d90c)
#16 0x000000000615f72c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x615f72c)
#17 0x000000000450e0fd clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x450e0fd)
#18 0x0000000004813b0a clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4813b0a)
#19 0x000000000478dffb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x478dffb)
#20 0x00000000049080c3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x49080c3)
#21 0x0000000000dc1375 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdc1375)
#22 0x0000000000db931d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#23 0x000000000457acf9 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
#24 0x0000000003b94103 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b94103)
#25 0x000000000457af19 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
#26 0x000000000453de7d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x453de7d)
#27 0x000000000453ee31 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+++0x453ee31)
#28 0x000000000454878c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x454878c)
#29 0x0000000000dbdb81 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdbdb81)
#30 0x0000000000c6d0b4 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc6d0b4)
#31 0x00007143efc29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#32 0x00007143efc29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#33 0x0000000000db8db5 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdb8db5)
Compiler returned: 1
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkmVtz4yrywD8NeaHsQkiy5Ic8KE58_jk1U5NK8j8P-6JCgBw2GLSActlPv4Uu1iXOTPaUzu7DTs3UWCCaH91NdyOIteKgOL8E8RWIry9I7Z60uXxeEWP0q70oNHu_vOeV0aym3IAwAyh7cq6y_ifeA7w_aFZo6dbaHADe_xPgfVrQ7W93OnkCKAMb1P6lVQVQlufEOSOK2vE8BzgFOFUvlXvLn7lRXAK8BXgLX7RgsNQa4FQoBwHODHe-AyRXAGWwa4EgvIYBCH0bSK7Hs_nfKLsi9NkZQnnLPbBoZbXkAGUlcURCboz2a2t_QKFgQegzV8y31crWVaWN4wxSIqVQB0i1euHKCa0Ayu6-3WQPN9DWxVE4SGBRH6DhfgR0Gs6UJdxTXaypPgK8l_Kl_29VGf13Th3Ae2FtzS3Ae0gUg0JRWTMO3ROH1BD71KC1i8I7WBlvG8qt5QxaXZu22Y8k1moqiMc2tYKWGlG5NUDZgyP0GbL6WLVqQWuAtndGHww5QmIO9ZEr55EhwHtdeSaqj5WQ3Kz4WyW14ca3SaIOK2d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