Issue 238160
Summary [ClangIR][AArch64] Assertion `Subtarget->isTargetDarwin() && "automatic va_arg instruction only works on Darwin"' failed.
Labels backend:AArch64, crash, llvm:SelectionDAG, ClangIR, generated by fuzzer
Assignees
Reporter k-arrows
    Reproducer:
https://godbolt.org/z/ss41qEKeG
```cpp
__builtin_va_list ap;
int v = __builtin_va_arg(ap, int);
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:13824: llvm::SDValue llvm::AArch64TargetLowering::LowerVAARG(llvm::SDValue, llvm::SelectionDAG&) const: Assertion `Subtarget->isTargetDarwin() && "automatic va_arg instruction only works on Darwin"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -Xclang -fclangir -fcolor-diagnostics -fno-crash-diagnostics -target aarch64 -O1 <source>
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '<source>'.
4.	Running pass 'AArch64 Instruction Selection' on function '@_GLOBAL__sub_I_example.cpp'
 #0 0x0000000004ee6928 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ee6928)
 #1 0x0000000004ee3b84 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ee3b84)
 #2 0x0000000004ee41bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ee41bc)
 #3 0x0000000004e1e468 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x000070a175845330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x000070a17589ec0c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9ec0c)
 #6 0x000070a17584527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #7 0x000070a1758288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #8 0x000070a17582881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #9 0x000070a17583b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x00000000017b0886 llvm::AArch64TargetLowering::LowerVAARG(llvm::SDValue, llvm::SelectionDAG&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x17b0886)
#11 0x00000000018448c0 llvm::AArch64TargetLowering::LowerOperation(llvm::SDValue, llvm::SelectionDAG&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x18448c0)
#12 0x00000000066a8c3d (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) (.part.0) LegalizeDAG.cpp:0:0
#13 0x00000000066bc1ee llvm::SelectionDAG::Legalize() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66bc1ee)
#14 0x00000000067be128 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67be128)
#15 0x00000000067c1b66 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67c1b66)
#16 0x00000000067c320c llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67c320c)
#17 0x00000000067abc3e llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67abc3e)
#18 0x000000000413b24d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#19 0x000000000479b0f3 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x479b0f3)
#20 0x000000000479b531 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x479b531)
#21 0x000000000479bef9 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x479bef9)
#22 0x000000000632df78 runCodeGenPipelineLegacy(llvm::TargetMachine&, llvm::Module&, llvm::raw_pwrite_stream&, llvm::raw_pwrite_stream*, llvm::CodeGenFileType, bool, bool) RunCodeGen.cpp:0:0
#23 0x000000000632e125 llvm::runCodeGenPipeline(llvm::TargetMachine&, llvm::Module&, llvm::raw_pwrite_stream&, llvm::raw_pwrite_stream*, llvm::CodeGenFileType, bool, bool, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x632e125)
#24 0x000000000530dcd2 (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
#25 0x000000000530e29f clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, 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+++0x530e29f)
#26 0x000000000609d430 cir::emitCIRModuleOutput(cir::CIRGenAction::OutputType, clang::CompilerInstance&, mlir::ModuleOp, llvm::LLVMContext&, llvm::SmallVectorImpl<clang::LinkModule>&, clang::BackendDiagnosticConsumer&, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, llvm::function_ref<void (llvm::Module&)>) CIRGenAction.cpp:0:0
#27 0x00000000060a0299 cir::CIRGenConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x60a0299)
#28 0x0000000008f49d5c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8f49d5c)
#29 0x000000000609e898 cir::CIRGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x609e898)
#30 0x0000000005d01e08 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d01e08)
#31 0x0000000005c8e9ad clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5c8e9ad)
#32 0x0000000005dd83f3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5dd83f3)
#33 0x0000000001715e48 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1715e48)
#34 0x000000000170cd2a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#35 0x000000000170ceb3 int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#36 0x0000000005a51dc9 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
#37 0x0000000004e1e864 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e1e864)
#38 0x0000000005a52935 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
#39 0x0000000005a100b2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5a100b2)
#40 0x0000000005a1336c 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+++0x5a1336c)
#41 0x0000000005a1f4a5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5a1f4a5)
#42 0x000000000171247a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x171247a)
#43 0x0000000001687b33 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1687b33)
#44 0x000070a17582a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#45 0x000070a17582a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#46 0x000000000170c6d5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x170c6d5)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Program terminated with signal SIGABRT (6)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to