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

Christophe Lyon <clyon at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
                 CC|                            |clyon at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Christophe Lyon <clyon at gcc dot gnu.org> ---
(In reply to Ravaz from comment #0)
[...]
> The instruction at 0x810c forces the address used for the ldrd to be
> alligned to an 8 bytes boundary. The problem is that the double parameter is
> passed on register r2-r3 and pushed on the stack at the entry point of 
> vargTest function. Since the stack is aligned on 4 bytes boundary only the
> double value may be misaligned and as a consequence the
> __builtin_va_arg(vaList, double) function fails to retrive the correct
> value. 
> 
> Is this a bug?

AFAIC, the ARM ABI (AAPCS) mandates that the stack is aligned on 8 bytes, so
r2/r3 are pushed on an 8 bytes boundary.

For the record, today's trunk generates (-O0):

vargTest:
        @ args = 4, pretend = 16, frame = 16
        @ frame_needed = 1, uses_anonymous_args = 1
        @ link register save eliminated.
        push    {r0, r1, r2, r3}
        str     fp, [sp, #-4]!
        add     fp, sp, #0
        sub     sp, sp, #20
        add     r3, fp, #8
        str     r3, [fp, #-16]
        ldr     r3, [fp, #-16]
        add     r3, r3, #7
        bic     r3, r3, #7
        add     r2, r3, #8
        str     r2, [fp, #-16]
        ldrd    r2, [r3]
        strd    r2, [fp, #-12]
        ldrd    r2, [fp, #-12]
        mov     r0, r2
        mov     r1, r3
        add     sp, fp, #0
        @ sp needed
        ldr     fp, [sp], #4
        add     sp, sp, #16
        bx      lr

and -O2:
vargTest:
        @ args = 4, pretend = 16, frame = 8
        @ frame_needed = 0, uses_anonymous_args = 1
        @ link register save eliminated.
        push    {r0, r1, r2, r3}
        sub     sp, sp, #8
        add     r3, sp, #19
        add     r2, sp, #12
        bic     r3, r3, #7
        ldrd    r0, [r3]
        str     r2, [sp, #4]
        add     sp, sp, #8
        @ sp needed
        add     sp, sp, #16
        bx      lr


So I think this is invalid.

Reply via email to