<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/131223>131223</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Clang Assertion Failure in `CodeGenModule::UpdateMultiVersionNames` with Recursive `Multi-versioned` Function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bi6c
</td>
</tr>
</table>
<pre>
Code explorer: [https://godbolt.org/z/rvrzh6rdj](https://godbolt.org/z/rvrzh6rdj)
generated by fuzzer
**Code:**
```c
int f_(void) __asm__("f");
int __attribute__((target_clones("default,avx"))) f(void) {
return f_();
}
int main(void) {
return f();
}
```
**stack trace:**
```
clang-21: /root/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:1987: void clang::CodeGen::CodeGenModule::UpdateMultiVersionNames(clang::GlobalDecl, const clang::FunctionDecl*, llvm::StringRef&): Assertion `OtherGD.getCanonicalDecl() .getDecl() ->getAsFunction() ->isMultiVersion() && "Other GD should now be a multiversioned function"' failed.
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-20250313/bin/clang-21 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir /app/output.s- -disable-free -clear-ast-before-backend -main-file-name example.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/app -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20250313/lib/clang/21 -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20250313/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/example-8fb254.o -x c <source>
1. <source>:7:1: current parser token 'int'
2. <source>:3:51: LLVM IR generation of declaration 'f'
3. <source>:3:51: Generating code for declaration 'f'
#0 0x0000000003e7dc08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x3e7dc08)
#1 0x0000000003e7b5c4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#2 0x0000702a32042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x0000702a320969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x0000702a32042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x0000702a320287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x0000702a3202871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x0000702a32039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x00000000043fc87a clang::CodeGen::CodeGenModule::UpdateMultiVersionNames(clang::GlobalDecl, clang::FunctionDecl const*, llvm::StringRef&) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x43fc87a)
#9 0x000000000443408a clang::CodeGen::CodeGenModule::GetOrCreateLLVMFunction(llvm::StringRef, llvm::Type*, clang::GlobalDecl, bool, bool, bool, llvm::AttributeList, clang::CodeGen::ForDefinition_t) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x443408a)
#10 0x0000000004436e68 clang::CodeGen::CodeGenModule::GetAddrOfFunction(clang::GlobalDecl, llvm::Type*, bool, bool, clang::CodeGen::ForDefinition_t) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x4436e68)
#11 0x00000000044371e9 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x44371e9)
#12 0x000000000443a3a4 clang::CodeGen::CodeGenModule::EmitMultiVersionFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x443a3a4)
#13 0x00000000044325a5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x44325a5)
#14 0x000000000443298b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x443298b)
#15 0x000000000443cd63 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#16 0x000000000483ad46 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#17 0x000000000482ad04 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x482ad04)
#18 0x000000000643bc44 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x643bc44)
#19 0x0000000004837528 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x4837528)
#20 0x0000000004b00005 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x4b00005)
#21 0x0000000004a8398e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x4a8398e)
#22 0x0000000004bedf9e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0x4bedf9e)
#23 0x0000000000d5391f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0xd5391f)
#24 0x0000000000d4b2da ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#25 0x0000000000d4f47b clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0xd4f47b)
#26 0x0000000000c17ff4 main (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0xc17ff4)
#27 0x0000702a32029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#28 0x0000702a32029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#29 0x0000000000d4ad85 _start (/opt/compiler-explorer/clang-assertions-trunk-20250313/bin/clang-21+0xd4ad85)
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 254
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMWV1v2ziz_jXMDUFDouQPXeRCteO8BdrTounpuTQociRzI5ECSblJf_0BKTmyXKfb9F0Du_CmFs2ZeZ7hcGZEMmtlpQBu0fwdmm9uWOf22twWcsFvCi2eb9daAIanttYGDEpyjObv9s61FiU5oltEt5UWha7dTJsK0e0PRLfmYH7sF0b8heYbRFe_P51mKMpRlFegwDAHAhfPuOx-_ADT_4Co_3hMQV_4RDlaRP2HoyiXyuFyh-jqoKVANMO7HbPNzo8gSktEqTeTvOsV-tm7HXPOyKJzMExbOWYqcDteawW2lxRQsq52iK7Z4WnQEj64PDGGll4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