<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62999>62999</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-17 crashes at clang::CodeGen::CodeGenFunction::EmitFunctionProlog
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wierton
</td>
</tr>
</table>
<pre>
When compile below code snippet with `clang-17 -O0`:
```
struct T {};
void __regcall f(struct T a) {}
```
`clang-17` outputs (reproduce at gcc.godbolt.org: https://gcc.godbolt.org/z/qWchhbn93):
```
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 --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 <source>
1. <eof> parser at end of file
2. <source>:3:16: LLVM IR generation of declaration 'f'
3. <source>:3:16: Generating code for declaration 'f'
#0 0x00005565f8fb505f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x361505f)
#1 0x00005565f8fb308c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x361308c)
#2 0x00005565f8f024c8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f626076a420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00005565f89b7cbc llvm::Value::setNameImpl(llvm::Twine const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3017cbc)
#5 0x00005565f89b7f9d llvm::Value::setName(llvm::Twine const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3017f9d)
#6 0x00005565f95e5099 clang::CodeGen::CodeGenFunction::EmitFunctionProlog(clang::CodeGen::CGFunctionInfo const&, llvm::Function*, clang::CodeGen::FunctionArgList const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3c45099)
#7 0x00005565f932ad8a clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, clang::QualType, llvm::Function*, clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::FunctionArgList const&, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk/bin/clang+0x398ad8a)
#8 0x00005565f932dce6 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x398dce6)
#9 0x00005565f9385b0a clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x39e5b0a)
#10 0x00005565f9381e85 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x39e1e85)
#11 0x00005565f93827f0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-trunk/bin/clang+0x39e27f0)
#12 0x00005565f938a30a clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#13 0x00005565fa1351be (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#14 0x00005565fa12680d clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-trunk/bin/clang+0x478680d)
#15 0x00005565fb502ea4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b62ea4)
#16 0x00005565fa132685 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4792685)
#17 0x00005565f9a16bf1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4076bf1)
#18 0x00005565f999a8f3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3ffa8f3)
#19 0x00005565f9af5b23 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4155b23)
#20 0x00005565f683a2fc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xe9a2fc)
#21 0x00005565f68359ff ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#22 0x00005565f97f731d 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
#23 0x00005565f8f02947 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3562947)
#24 0x00005565f97f755c 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
#25 0x00005565f97bef9e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e1ef9e)
#26 0x00005565f97bf96d 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+0x3e1f96d)
#27 0x00005565f97ca03c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e2a03c)
#28 0x00005565f6837eff clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xe97eff)
#29 0x00005565f6735245 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xd95245)
#30 0x00007f6260218083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#31 0x00005565f6831cde _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xe91cde)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWV1v2zrS_jXMDWGDoj4sXeTCceK-Pch5T7cJei4NihrJ2tKklqTysb9-QUl2RNV2t3HOYoEF2tgmhzPPPDMcjkRmTF1JgGsU36D49oq1dqv09XMN2ip5lavi9frPLUjM1a6pBeAchHrGXBWAjaybBix-ru0Wo4RwwWQ1CxZ49gdBCUHhEpFbRJbue_-v-2msbrnFjxgtbtDiFoU3g1j390nVBd5sNFScCYFLRNPDAoZotl91TPNhcI8EJQSr1jatNRjRVEOjVdFywMziivN5pYpcCTtXukLhEm-tbYyDTdeIrqcCdP1PRNf_-JNvt7nMQkSzUx5-ub9bPtxh0-a72mKG87bCGhqlLbZqaqW22zafc7VDdC3E0_5j1mj1d-AW0XVtTAsG0TVmssC15KItANstYK6Z2eKc8e9WMw6IrnDTOcnBGCiwUa3uh91KZoziNbNQYN1KbLiuGzvvIT9Yxr_jot01B6fIHJHsi1aVZjvMdNXuQFoHHCO6Vo1DNiSFnsFLI5QG7cY67q1u5XdE13kt92N4VhXPTJezCM8qPFNODWsap6wL0dzg2QOezSrOZ1Ypwbeslii8PWvNCWdzOid4VnIllJ4VNaukMrbmBs9KqWYdSf7wHwSjcDWwE971_gbOXxSuQJUovMMN0wa0yxSQBVYlLmsBvSQdJN8UhMsQhcsgcezc33_7HX_-iiuQoJmtlXSrC-CCDT8RXZSILnpl4VllnwYlsur3XKn0aVUY0ZBg8kIIIXGc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