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

--- Comment #7 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
However while writing the patch "Sanitizing the middle-end interface
to the back-end for strict alignment":
https://gcc.gnu.org/ml/gcc-patches/2019-08/msg01130.html

I discovered another wrong code bug, this time affecting all arch:

$ cat unaligned-argument-3.c 
/* { dg-do compile } */
/* { dg-require-effective-target arm_arm_ok } */
/* { dg-require-effective-target arm_ldrd_strd_ok } */
/* { dg-options "-marm -mno-unaligned-access -O3" } */

typedef int __attribute__((aligned(1))) s;

void x(char*, s*);
void f(char a, s f)
{
  x(&a, &f);
}

/* { dg-final { scan-assembler-times "str\t\[^\\n\]*\\\[sp\\\]" 1 } } */
/* { dg-final { scan-assembler-times "str\t\[^\\n\]*\\\[sp, #3\\\]" 0 } } */

currently with -marm -mno-unaligned-access -O3 we generate:

f:
        @ args = 0, pretend = 0, frame = 8
        @ frame_needed = 0, uses_anonymous_args = 0
        str     lr, [sp, #-4]!
        sub     sp, sp, #12
        mov     r3, r0
        str     r1, [sp, #3]
        add     r0, sp, #7
        add     r1, sp, #3
        strb    r3, [sp, #7]
        bl      x
        add     sp, sp, #12
        @ sp needed
        ldr     pc, [sp], #4

Reply via email to