Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result pointer in fastcall changed between clang 18 and clang 20 #112519

Open
Yehouda opened this issue Oct 16, 2024 · 0 comments
Open

Result pointer in fastcall changed between clang 18 and clang 20 #112519

Yehouda opened this issue Oct 16, 2024 · 0 comments

Comments

@Yehouda
Copy link

Yehouda commented Oct 16, 2024

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__ */

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Oct 16, 2024
@EugeneZelenko EugeneZelenko added llvm:optimizations and removed clang Clang issues not falling into any other category labels Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants