<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/70402>70402</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang crashes when targetting wasm32 with experimental-mv abi
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
TerrorJack
</td>
</tr>
</table>
<pre>
Minimal repro:
```c
float crealf() {
return 0;
}
```
When compiled with `clang --target=wasm32 -mmultivalue -c asdf.c -o asdf.o`, it compiles fine. When `-Xclang -target-abi -Xclang experimental-mv` is added to the command line, `clang` crashes with the following error:
```
Stack dump:
0. Program arguments: /workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang -mmultivalue -Xclang -target-abi -Xclang experimental-mv -c asdf.c -o asdf.o
1. <eof> parser at end of file
2. asdf.c:1:7: LLVM IR generation of declaration 'crealf'
3. asdf.c:1:7: Generating code for declaration 'crealf'
#0 0x000055cd3e5e46b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /workspace/wasi-sdk/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
#1 0x000055cd3e5e28a0 llvm::sys::RunSignalHandlers() /workspace/wasi-sdk/src/llvm-project/llvm/lib/Support/Signals.cpp:106:18
#2 0x000055cd3e561e2c (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /workspace/wasi-sdk/src/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
#3 0x000055cd3e561e2c CrashRecoverySignalHandler(int) /workspace/wasi-sdk/src/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:390:51
#4 0x00007fc6b1e12520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x000055cd40b658a7 clang::TagType::getDecl() const /workspace/wasi-sdk/src/llvm-project/clang/lib/AST/Type.cpp:3768:32
#6 0x000055cd3ed2d5b7 clang::RecordDecl::fields() const /workspace/wasi-sdk/src/llvm-project/clang/include/clang/AST/Decl.h:4293:51
#7 0x000055cd3ed2d5b7 WebAssemblyABIInfo::classifyArgumentType(clang::QualType) const /workspace/wasi-sdk/src/llvm-project/clang/lib/CodeGen/Targets/WebAssembly.cpp:120:41
#8 0x000055cd3ed2d9fe WebAssemblyABIInfo::computeInfo(clang::CodeGen::CGFunctionInfo&) const /workspace/wasi-sdk/src/llvm-project/clang/lib/CodeGen/Targets/WebAssembly.cpp:41:16
#9 0x000055cd3ea057af clang::CodeGen::ABIArgInfo::isDirect() const /workspace/wasi-sdk/src/llvm-project/clang/include/clang/CodeGen/CGFunctionInfo.h:296:34
#10 0x000055cd3ea057af clang::CodeGen::ABIArgInfo::canHaveCoerceToType() const /workspace/wasi-sdk/src/llvm-project/clang/include/clang/CodeGen/CGFunctionInfo.h:306:12
#11 0x000055cd3ea057af clang::CodeGen::CodeGenTypes::arrangeLLVMFunctionInfo(clang::CanQual<clang::Type>, clang::CodeGen::FnInfoOpts, llvm::ArrayRef<clang::CanQual<clang::Type>>, clang::FunctionType::ExtInfo, llvm::ArrayRef<clang::FunctionType::ExtParameterInfo>, clang::CodeGen::RequiredArgs) /workspace/wasi-sdk/src/llvm-project/clang/lib/CodeGen/CGCall.cpp:806:15
#12 0x000055cd3ea05bfe arrangeLLVMFunctionInfo(clang::CodeGen::CodeGenTypes&, bool, llvm::SmallVectorImpl<clang::CanQual<clang::Type>>&, clang::CanQual<clang::FunctionProtoType>) /workspace/wasi-sdk/src/llvm-project/clang/lib/CodeGen/CGCall.cpp:195:14
#13 0x000055cd3ea06fad clang::CodeGen::CodeGenTypes::arrangeFreeFunctionType(clang::CanQual<clang::FunctionProtoType>) /workspace/wasi-sdk/src/llvm-project/clang/lib/CodeGen/CGCall.cpp:204:10
#14 0x000055cd3ea06fad clang::CodeGen::CodeGenTypes::arrangeFunctionDeclaration(clang::FunctionDecl const*) /workspace/wasi-sdk/src/llvm-project/clang/lib/CodeGen/CGCall.cpp:471:10
#15 0x000055cd3ec6875b clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) /workspace/wasi-sdk/src/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:5658:41
#16 0x000055cd3ec62805 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) /workspace/wasi-sdk/src/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:0:12
#17 0x000055cd3ec6617d clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) /workspace/wasi-sdk/src/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3691:5
#18 0x000055cd3ec617f1 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) /workspace/wasi-sdk/src/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:6590:5
#19 0x000055cd3ecf0b6c (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) /workspace/wasi-sdk/src/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:189:73
#20 0x000055cd3ec4052d clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) /workspace/wasi-sdk/src/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:237:11
#21 0x000055cd3fd67dda clang::ParseAST(clang::Sema&, bool, bool) /workspace/wasi-sdk/src/llvm-project/clang/lib/Parse/ParseAST.cpp:167:11
#22 0x000055cd3ef7b017 clang::FrontendAction::Execute() /workspace/wasi-sdk/src/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1074:10
#23 0x000055cd3eefe964 llvm::Error::getPtr() const /workspace/wasi-sdk/src/llvm-project/llvm/include/llvm/Support/Error.h:279:12
#24 0x000055cd3eefe964 llvm::Error::operator bool() /workspace/wasi-sdk/src/llvm-project/llvm/include/llvm/Support/Error.h:239:16
#25 0x000055cd3eefe964 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /workspace/wasi-sdk/src/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1045:23
#26 0x000055cd3eff1080 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /workspace/wasi-sdk/src/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:272:25
#27 0x000055cd3d7587ea cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /workspace/wasi-sdk/src/llvm-project/clang/tools/driver/cc1_main.cpp:294:15
#28 0x000055cd3d755b56 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /workspace/wasi-sdk/src/llvm-project/clang/tools/driver/driver.cpp:366:12
#29 0x000055cd3ed74469 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0::operator()() const /workspace/wasi-sdk/src/llvm-project/clang/lib/Driver/Job.cpp:440:30
#30 0x000055cd3ed74469 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::$_0>(long) /workspace/wasi-sdk/src/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#31 0x000055cd3e561c65 llvm::function_ref<void ()>::operator()() const /workspace/wasi-sdk/src/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:0:12
#32 0x000055cd3e561c65 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /workspace/wasi-sdk/src/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:426:3
#33 0x000055cd3ed73e26 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const /workspace/wasi-sdk/src/llvm-project/clang/lib/Driver/Job.cpp:440:7
#34 0x000055cd3ed3f327 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /workspace/wasi-sdk/src/llvm-project/clang/lib/Driver/Compilation.cpp:0:15
#35 0x000055cd3ed3f57e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const /workspace/wasi-sdk/src/llvm-project/clang/lib/Driver/Compilation.cpp:253:13
#36 0x000055cd3ed59c1c llvm::SmallVectorBase<unsigned int>::empty() const /workspace/wasi-sdk/src/llvm-project/llvm/include/llvm/ADT/SmallVector.h:94:46
#37 0x000055cd3ed59c1c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) /workspace/wasi-sdk/src/llvm-project/clang/lib/Driver/Driver.cpp:1884:23
#38 0x000055cd3d755581 clang_main(int, char**, llvm::ToolContext const&) /workspace/wasi-sdk/src/llvm-project/clang/tools/driver/driver.cpp:542:21
#39 0x000055cd3d762b61 main /workspace/wasi-sdk/build/llvm/tools/clang/tools/driver/clang-driver.cpp:15:3
#40 0x00007fc6b1df9d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#41 0x00007fc6b1df9e40 call_init ./csu/../csu/libc-start.c:128:20
#42 0x00007fc6b1df9e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#43 0x000055cd3d752765 _start (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang+0x11a3765)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 18.0.0 (git@gitlab.haskell.org:ghc/llvm-project.git cadb2a4dec286dc68eda5a143d025701406f5918)
Target: wasm32-unknown-wasi
Thread model: posix
InstalledDir: /workspace/wasi-sdk/build/install/opt/wasi-sdk/bin
clang: note: diagnostic msg:
********************
```
The LLVM version above is based on latest `master`. The same crash is also present with `clang-17` installed by the official apt repo on Ubuntu 22.04.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWltv27jy_zTKC2FDoq5-y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