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

            Bug ID: 92223
           Summary: Redundant pushing to stack when passing empty structs
                    to function (x32)
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lahav.sch.gcc at gmail dot com
  Target Milestone: ---

Hi!

I tested the following code in several version of GCC, including trunk.

In the following code:


struct Empty {};

void foo(int, Empty, int);

int main() {
    foo(10, Empty{}, 15);
}


The call to foo compiles to:

pushl   $0xf
pushl   $0x0
pushl   $0xa
call    foo(int, Empty, int)


A similar issue was fixed in the GCC 8.1 release, but only for x86-64 - In x64
the Empty parameter is now completely removed (Instead of passing an dummy 0
value on the stack), but in x32 it still remains.

I'm not sure if the x32 ABI mandates that such empty classes should be
completely removed (In contrast with the System V x86-64 ABI which states they
indeed should not be passed).

In pre-GCC 8 version on x86-64 a similar behaviour happend - 0xa was into $edi,
the 0xf was passed to $esi, but there was a "pushq $0x0" to the stack.
Perhaps the two behaviour are related?

Reply via email to