<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64662>64662</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc++] `__throw_bad_function_call` should be `cold` and `noinline`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Eisenwave
</td>
</tr>
</table>
<pre>
https://github.com/llvm/llvm-project/blob/a7d80c50aa9121bff08d59ab4c4d7210dd2400f9/libcxx/include/__functional/function.h#L75-L83
This function should ideally be marked `cold` and `noinline`, since throwing exceptions is meant to be expensive and unusual anyway, and inlining just increases the code size at the call site.
The [libstdc++ counterpart](https://github.com/gcc-mirror/gcc/blob/25be11e982c76200fabb375c8c63eff8c6856980/libstdc%2B%2B-v3/include/bits/functexcept.h#L114C10-L114C10) is marked `cold`, and is opaque, which prevents inlining.
```cpp
void
__throw_bad_function_call() __attribute__((__noreturn__,__cold__));
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE2P4ygU_DX4ghIBDhgffJh0b05z3LvFx3PMLAEv4KR7f_0Ke5LRrLQjjYQMlK3iUfXKKmd3DQAD4mfE3xu1ljmm4Q-XITzUHRod7ecwl7Jk1H5B7ILY5erKvOqjiTfELt7fn9NhSfEbmILYRfuoEbuozkpiOFGqp4zqaSLS8l7pkznZjlFiLTsRMvWVwGnz8YHYxQXjVwuIXcZxWoMpLgblEbs8N8cZsfZrxw9fZYvIOyJf9uefs8v4-RHOc1y9xc6C8v4Ta8A3lf4Ci5EgJnqLBMEqbNsQXfAuABIEsTecXTCAy5ziw4Urhg8DS6XM2GV8AxUKLrESwscCIbs7bERrWPOqPFbh86E-K1FFN-ZK823NBbtgEqgMGZcZsIkWcHb_AFZlB5T3OLsCx5_vBRjxs3c6F2sQOyN2xiauoUBaVCqIvyMmf2HR1ZjDzaUU07754Q_jGiiFXjLTCUbIpLRuO26kES1MkzRCctFLsvuzH89rAZydD_f2J7e0K_np0q7ZbhSlpzdKDt9nxPpNxv968dIr47iov1eowGN2ZsZLgjuEkl9aPtURZB9mWXYE36Oz35d4HDcLR63sq4_GqjBislYxjqqU5PRaYBw3TI5jiAnKmkJF3saxFleXfR3t-Un9OrmxQ2v7tlcNDFT0tBdd2_FmHiahJzExbk03EasolVZykJM0lLRSscYNjLCWSNoyxgXlR8ml4qo1UlCqOpjQicBNOX-syTrGdG1czisM4iQEa7zS4PMWWsYCPPD2EjFWM5yGLY16vWZ0It7lkn-wFFf8lvYauL2ZEH-vV_p_wQR5xknDr_PTrMn__t9iK742z3a5fwMAAP__bbBydg">