https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106977

--- Comment #23 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to ibuclaw from comment #21)
> There is something about the Darwin ABI I'm just not getting from looking at
> the front-end alone though:
> 
> C++ Darwin 32-bit calling a method that returns an 8 byte struct:
> ```
> __Z4testP3Bar:
>         subl    $24, %esp
>         movl    28(%esp), %eax
>         movl    (%eax), %edx
>         pushl   %eax            // <--
>         call    *(%edx)
> ```

Darwin does not need an "sret" parameter since it will return the struct in
registers.
So it only passes "this".

> C++ Linux 32-bit calling a method that returns an 8 byte struct:
> ```
> _Z4testP3Bar:
>         subl    $44, %esp
>         movl    %gs:20, %edx
>         movl    %edx, 28(%esp)
>         xorl    %edx, %edx
>         movl    48(%esp), %eax
>         leal    8(%esp), %ecx
>         subl    $8, %esp
>         movl    (%eax), %edx
>         pushl   %eax            // <--
>         pushl   %ecx            // <--
>         call    *(%edx)
> ```

The Linux (SysV ABI arch-specific addition) says that structures are returned
via an sret param - for all size of struct.


So the ABIs differ in this (as noted on IRC, the Darwin 32b ABIs are not the
same as Linux).

Reply via email to