<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/123935>123935</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[X86] __int128 parameters cause wrong location for subsequent i64
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:X86,
ABI
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
aengelke
</td>
</tr>
</table>
<pre>
For this code:
```c++
long call8(long, __int128, __int128, __int128, long x) {
// IR signature from Clang: define i64 @call8(i64, i64, i64, i64, i64, i128, i64)
return x;
}
```
- GCC passes parameters in (rdi), (rsi, rdx), (rcx, r8), ([rsp+8], [rsp+16]), (r9).
- Clang/LLVM passes paremeters in (rdi), (rsi, rdx), (rcx, r8), ([rsp+8], [rsp+16]), ([rsp+24]).
Since fa1b6e6b34eb6382c451f3a06a7c52d7ac6ada1d, the i128 is no longer split between register and stack, but the SysV ABI also states:
> If there are no registers available for any eightbyte of an argument, the whole argument is passed on the stack. If registers have already been assigned for some eightbytes of such an argument, the assignments get reverted.
I (and GCC) read this as: the entire i128 gets passed on the stack and r9 becomes allocatable again. ([Godbolt](https://godbolt.org/z/zE3E3n7eP)) `CCAssignToStackWithShadow`allocates `r9`, but I think this should just be an `CCAssignToStack` that doesn't allocate r9.
Originally found by @pfent; cc @nikic
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VE9v47YT_TT0ZRBDov4fdLCdODCwP_yKptj2thiRI4kbmnRJKon76QvSdhK0iz0WoGFyqJk373Fm0Hs1GaKeVVtW3a9wCbN1PZKZSD_TarDy3O-tgzArD8JKYsWGZWnV2WUJxrdxZRttzQQCtW4Zb-OB8R18-6ZMyHn7s31yfGO8A9bEQAAAjO8Z38PhV4gpYlgcwejsEXYazcSKDUgalSFQdQmszG64qi5jyJ_-XWHTsbviOQqLM_DGipgBa-4_c7xQvoPH3Q5O6D15OKHDIwVyHpQBxlsnVYz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