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

            Bug ID: 83330
           Summary: [7/8 Regression] generating unaligned store to stack
                    for SSE register with -mno-push-args
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu

Created attachment 42816
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42816&action=edit
reduced testcase

Output:
$ x86_64-pc-linux-gnu-gcc -O2 -fno-tree-dce -mno-push-args testcase.c
$ ./a.out 
Segmentation fault


foo() disassembly:

foo:
        sub     rsp, 16
        pxor    xmm0, xmm0
        movaps  XMMWORD PTR [rsp], xmm0 <== crashes HERE
        pop     rax
        mov     rax, QWORD PTR g[rip]
        pop     rdx
        ret

According to the ABI, rsp is aligned to 16 bytes before the function call;
thus, rsp % 16 == 0 at the point of crash.

Also, I do not understand why bar() is apparently inlined, when the function
has noinline,noclone attributes (noipa helps; -fno-ipa-pure-const helps too);
but "noipa" implies just noinline,noclone,no_icf according to
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes

Reply via email to