<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112519>112519</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Result pointer in fastcall changed between clang 18 and clang 20
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Yehouda
</td>
</tr>
</table>
<pre>
The C file below is automaticlly generated by our test-suite, and then we call it from lisp to test the calling convention.
On x86 32bit freebsd, compiling with clang 18.1.8, the function fastcall_k_6 expects the pointer to the return value to be in ECX,
Compiling with clang 20.0.0git it expects the pointer to the return value to be on the stack.
Is this difference intentional?
Is it documented anywhere?
[BTW: why cannot attach a C file?]
------- start of fastcall_k_6 with 18.1.8 ------------------
```
0x20 <fastcall_k_6>: push %ebp
0x21 <fastcall_k_6+1>: mov %esp,%ebp
0x23 <fastcall_k_6+3>: push %esi
0x24 <fastcall_k_6+4>: push %eax
0x25 <fastcall_k_6+5>: call 0x2a <fastcall_k_6+10>
0x2a <fastcall_k_6+10>: pop %edx
0x2b <fastcall_k_6+11>: add $0x3,%edx
0x31 <fastcall_k_6+17>: mov %ecx,%eax << expects ecx to contain the pointer to the result
0x33 <fastcall_k_6+19>: mov %ecx,-0x8(%ebp)
0x36 <fastcall_k_6+22>: mov 0x0(%edx),%esi
0x3c <fastcall_k_6+28>: mov %esi,(%ecx)
```
-----------------------------------------------------------------------------
----- start of fastcall_k_6 with 20.0.0git ------------------------------------
```
0x1470 <fastcall_k_6>: push %ebp
0x1471 <fastcall_k_6+1>: mov %esp,%ebp
0x1473 <fastcall_k_6+3>: push %esi
0x1474 <fastcall_k_6+4>: call 0x1479 <fastcall_k_6+9>
0x1479 <fastcall_k_6+9>: pop %edx
0x147a <fastcall_k_6+10>: add $0x2193,%edx
0x1480 <fastcall_k_6+16>: mov 0x8(%ebp),%ecx << expects ebp+8 to contain a pointer to the result
0x1483 <fastcall_k_6+19>: mov %ecx,%eax
0x1485 <fastcall_k_6+21>: mov -0x32dc(%edx),%esi
0x148b <fastcall_k_6+27>: mov %esi,(%ecx)
```
-----------------------------------------------------------------------------
-------------------------- fastcall_c_struct.c ----------------------------------------------
```
#include <stdio.h>
typedef union { long long l ; double d ; } res_val_union;
typedef struct fastcall_a_struct { long long slot_a ; double slot_b ; } fastcall_a_struct;
#define FASTCALL_ATTRIBUTE __attribute__ ((fastcall))
#ifdef __GNUC__
static res_val_union fastcall_results_vector[100] ;
res_val_union* fastcall_type_results_6(void) { return fastcall_results_vector ;}
fastcall_a_struct FASTCALL_ATTRIBUTE fastcall_k_6()
{
{ fastcall_a_struct aa = {50, 1.0} ; return aa ;}
}
#else /* __GNUC__ */
res_val_union* fastcall_type_results_6(void) { return NULL ;}
#endif /* __GNUC__ */
```
--------------------------------------------------------------------------------------------------------
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMV1Fv4jgX_TXm5QpkOwlJHngAOnwaqZpPmu1od58ixzbEO8FGsUPTf7-ySYGUlM5odqWNqrSQe86991wfN2bWqp2WcoGSFUoeJqx1lWkWf8rKtIJNSiNeFk-VhDVsVS2hlLV5BmWBtc7smVO8rl9gJ7VsmJMCyhcwbQNOWje1rXIS0TUwLcBVUsOzBM7qGpSDbWP2UCt7AGdCuI8IT5XeATf6KLVTRs8A4QeEl__X0GVziGgZwFKWVnhubvYHFTDPylXAa6Z3QLIZmWX-sSfdtpp7Ktgy63yG4nsxB9kdJHc2RByM0k42oZRKQiNd22g4srqV_rtSgtLwaf0HoutTNeuxrBTP8AzvlPP9_Ry90eGJdYx_f-34swcrC0Jtt7KRmvsq3EkVVqNoc4lTDoTh7V5qPwOmX54r2UgUbU4RKFmtnn5H0RKeqxfgTGvjgDnHeAWsn6wPTh76-HCfni7wVTUOzHaoX2j8JDRMb65rIjTH_U_4iDuKAUXrazYUfULREuH80NoKABBNZHk4xQMA7ii5gdAVOcP25gg9zB78lG7w0Qg-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