<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113747>113747</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] __attribute__((__noreturn__)) miscompile
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ZijunZhaoCCK
</td>
</tr>
</table>
<pre>
`__attribute__((__noreturn__))` is miscompiled upstream.
See https://godbolt.org/z/T6nMoa75G from Miguel Young and his comment.
```
When using the standard [[noreturn]] and _Noreturn in their respective languages, codegen is identical, and correct. The C codegen is obviously wrong and clearly confusing the hell out of LLVM, as evidenced by this instruction sequence:
jne .LBB1_1
mov rax, qword ptr [rip + baz@GOTPCREL]
call rax
.LBB1_1: mov rax, qword ptr [rip + foo@GOTPCREL] call rax
(Just do call foo@PLT?)
My recommendation is that upstream use _Noreturn, or noreturn + <stdnoreturn.h>. Clang is clearly able to get this right, but somehow left hand isn't talking to right hand in the unification algorithm.
(This really isn't a C v. C++ difference at all; both languages define their standard noreturn primitives identically.)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVMGO4zYM_RrlQqzhyLEzPviwyWwWaGfaRRu06F4CWaJtTWUpK1GZZr--kOMkM3soChg2TIqP5OMTRQi6t4gNKzesfFyISIPzzVf9Eu3XQbjt9udF69S5YVV-OAgir9tIeDgw_sD4w-FgnUeK3iZLnZ4qBx1g1EG68agNKojHQB7FmLH8keUff0eEgegYWPGR8R3ju96p1hnKnO8Z331nfLev7LMT6_IzdN6N8Kz7iAb-ctH2IKyCQQeQbhzR0ow6v6t8fqbfPwe0EIO2PdCAEEhYJbyCqdnNtXRWPrLyccI9_DLbQNsUoj14DEeUpE8IRtg-ih4D41uQTmGPNjWrFVrSUphkTzDSeY-SMtgPCO-OuvakXQzmDK_ezc1Ig8KbM0hnu3uxAxoDLhK4Dp6e_niesAPgKWWTqKA9AyUetA3koyTtLAT8FpM3UfuGFgCAF4vpA9nTZrM8LGfH6E6T1Yt_UoJvr84rOJJPFHl9BMY30IrvbJV__nX_Zfvbp6fE1g1UCmOu4ZPxil5coP8LtnPuPewF7QY1v_nDTzEQKHdxX6K-PO1ZsUtye3P0-QweL6pQYqJDB6BB0E2BEAPeZ5wqcx6uMpiKYsU2kLqasoEVnzLYpsEnsOukRGsQyEGPdJmB1_1ACa-NBMGNOLhXMNgRDGnCOljG1wQkzN_TfN0lYvZOUoNodaflpXBheuc1DWP2Axf7KRsKY843VAFbOGWwZXyTWlC669AnFYAgEMawYgOto-GuX1DYaYuzwm_X4sbE0etRJ8m_0bY5Z3e-31-zhWoKVRe1WGCzXPO6znlZ88XQdGX5UNUltrWqZIXr4qFargpeI2_LqlbtQjc856tlzqs853XJs_Wqkly2RaVEVyteslWOo9AmM-Y0pgWx0CFEbJbLYr1aL4xo0YRpeXEuU3-M87THfJMCPrSxD2yVGx0o3CFIk5k23iWifIT_tdreLLVF9Kb5YYlpGmKbSTcyvkup5s-Ho3cvKInx3VR6YHw3V39q-L8BAAD__-BvxBk">