[Bug target/88469] AAPCS - Struct with 64-bit bitfield may be passed in wrong registers

rearnsha at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Dec 13 17:20:00 GMT 2018


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

--- Comment #4 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Simpler test-case.

struct x
{
  long long a : 61;
};

void bar (int, struct x);

int foo (int a, int b, int c, struct x d)
{
  bar (a, d);
  return 2;
}

This does not seem to generate ldrd, but does show that 'd' is passed partially
in r3 and partially on the stack, when it should be entirely on the stack.

Correct code should be something like:

        push    {r4, lr}
        ldrd    r2, [sp, #8]
        bl      bar
        mov     r0, #2
        pop     {r4, pc}

But we currently generate:

        sub     sp, sp, #8
        push    {r4, lr}
        ldr     r2, [sp, #16]
        mov     r1, r3
        str     r3, [sp, #12]
        bl      bar
        pop     {r4, lr}
        mov     r0, #2
        add     sp, sp, #8
        bx      lr


More information about the Gcc-bugs mailing list