<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/124852>124852</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc] register exhaustion with gcc-14
</td>
</tr>
<tr>
<th>Labels</th>
<td>
build-problem,
libc
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nickdesaulniers
</td>
</tr>
</table>
<pre>
llvm-project/libc/src/__support/threads/linux/thread.cpp fails to compile for me with gcc-14:
```
In file included from /android0/llvm-project/libc/src/__support/CPP/type_traits/integral_constant.h:11,
from /android0/llvm-project/libc/src/__support/CPP/type_traits/has_unique_object_representations.h:11,
from /android0/llvm-project/libc/src/__support/CPP/atomic.h:12,
from /android0/llvm-project/libc/src/__support/threads/thread.h:12,
from /android0/llvm-project/libc/src/__support/threads/linux/thread.cpp:9:
In function ‘long int __llvm_libc_20_0_0_git::syscall_impl(long int, long int, long int)’,
inlined from ‘R __llvm_libc_20_0_0_git::syscall_impl(long int, Ts ...) [with R = long int; Ts = {void*, long unsigned int}]’ at /android0/llvm-project/libc/src/__support/OSUtil/linux/syscall.h:34:49,
inlined from ‘void __llvm_libc_20_0_0_git::free_stack(void*, size_t, size_t)’ at /android0/llvm-project/libc/src/__support/threads/linux/thread.cpp:128:37,
inlined from ‘void __llvm_libc_20_0_0_git::cleanup_thread_resources(ThreadAttributes*)’ at /android0/llvm-project/libc/src/__support/threads/linux/thread.cpp:153:15,
inlined from ‘int __llvm_libc_20_0_0_git::Thread::run(__llvm_libc_20_0_0_git::ThreadStyle, __llvm_libc_20_0_0_git::ThreadRunner, void*, void*, size_t, size_t, bool)’ at /android0/llvm-project/libc/src/__support/threads/linux/thread.cpp:335:29:
/android0/llvm-project/libc/src/__support/macros/attributes.h:28:25: error: ‘asm’ operand has impossible constraints or there are not enough registers
28 | #define LIBC_INLINE_ASM __asm__ __volatile__
| ^~~~~~~
/android0/llvm-project/libc/src/__support/OSUtil/linux/x86_64/syscall.h:39:3: note: in expansion of macro ‘LIBC_INLINE_ASM’
39 | LIBC_INLINE_ASM("syscall"
| ^~~~~~~~~~~~~~~
```
If I change the arity-2 syscall to use just `asm` rather than `LIBC_INLINE_ASM` (removing the `volatile` qualifier), we do not observe register exhaustion. It's not immediately clear why that would fail; only with gcc and only with newer gcc, but I've been of the opinion that `LIBC_INLINE_ASM` needs to die. I'd rather put [[nodiscard]] on our syscall wrappers. Found while trying to test #124036.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8V19v27oO_zTKC7HAlhPHfshDmq5AgN3dYdt9FmSbibXJkqc_SXMf7me_oJImRbazHvRsU4tUUCiSP_JHipXeq51BXLL5HZvfT2QMvXVLo9qvHXoZtVHo_KSx3XGp9X54Mzr7BdvA-INWTcv4g3f0KYSP42gdfRF6h7LzScTEx8vJtB1H2EqlPQQLrR1GpRG21sGAcFChh13bvslnrFixbMXK7PybrTYGtiSrTKtjhx1snR2A8QdpOmdVl5Gtv-nd-sMH8ug4oghOqkB-KhNw56QWrTU-SBOmPStWec74mmUruF2_2HovvYhGfYsobEMKhMPRoUcTZFDW-N_sjQx2UO3JCP_1Rq50ONPg9xv6nnesWNUnXhGXomkpsMDeclZlrK60NTtQJoAQZE2QDcEzQT87FehmsfJH30qthRpGzfjlDuNr-PG-ftJfX8Eqo5W5MPjJ_sfXGv7sYTqdMl4Dm9-lGvoIrLi_OlHckQwdscXd3qqO8dXFy2hS9XdJcnHP5vcXj0GGV6bh35_-E5R-loWz-ynvBVX37MV4kKM_DcnWIQofZPuV8eoZLK_-iyI839W_ANILzMp5RdAW_xhVq1GaOIqTduHQ2-ha9IxXn9PRKgSnmhjoaPVnsM2L9PkStpeK5-T_ae-iYbx6WfpTOGqkXL4s-jEag45kn5Hhp7xYQ2Ot_iMxLIo5K1b83IBeZ2KQrbM-desnCqSCStTjpB_QOetoc0mK9MMVnR3RSdNBLz2oYbTeq0YjpCfPSWWCB-sg9OgQpE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