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

--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
clang 5.0 handles stack alignment correctly:

[hjl@gnu-skl-1 pr79793]$ cat x.c
typedef unsigned int uword_t __attribute__ ((mode (__word__)));

__attribute__((interrupt))
void
fn (void *frame)
{
  char fxsave_region [512] __attribute__((aligned(16)));
  __builtin_ia32_fxsave (fxsave_region);
}
[hjl@gnu-skl-1 pr79793]$ cat y.c
typedef unsigned int uword_t __attribute__ ((mode (__word__)));

__attribute__((interrupt))
void
fn (void *frame, uword_t error)
{
  char fxsave_region [512] __attribute__((aligned(16)));
  __builtin_ia32_fxsave (fxsave_region);
}
[hjl@gnu-skl-1 pr79793]$ make 
/export/build/gnu/llvm-clang/build-x86_64-linux/bin/clang -O2
-mgeneral-regs-only -S -o y.s y.c
clang-5.0: warning: argument unused during compilation: '-mgeneral-regs-only'
[-Wunused-command-line-argument]
[hjl@gnu-skl-1 pr79793]$ cat x.s
        .text
        .file   "x.c"
        .globl  fn                      # -- Begin function fn
        .p2align        4, 0x90
        .type   fn,@function
fn:                                     # @fn
        .cfi_startproc
# BB#0:                                 # %entry
        subq    $392, %rsp              # imm = 0x188
.Lcfi0:
        .cfi_def_cfa_offset 400
        cld
        fxsave  -128(%rsp)
        addq    $392, %rsp              # imm = 0x188
        iretq
.Lfunc_end0:
        .size   fn, .Lfunc_end0-fn
        .cfi_endproc
                                        # -- End function

        .ident  "clang version 5.0.0 (http://llvm.org/git/clang.git
f53edbb006df3bc205bf38008d96de510b2adddd) (http://llvm.org/git/llvm.git
9889fe2290766430b99a2d4fadbc5ba92f8004b6)"
        .section        ".note.GNU-stack","",@progbits
[hjl@gnu-skl-1 pr79793]$ cat y.s
        .text
        .file   "y.c"
        .globl  fn                      # -- Begin function fn
        .p2align        4, 0x90
        .type   fn,@function
fn:                                     # @fn
        .cfi_startproc
# BB#0:                                 # %entry
        pushq   %rax
        subq    $400, %rsp              # imm = 0x190
.Lcfi0:
        .cfi_def_cfa_offset 408
        cld
        fxsave  -120(%rsp)
        addq    $400, %rsp              # imm = 0x190
        addq    $16, %rsp
        iretq
.Lfunc_end0:
        .size   fn, .Lfunc_end0-fn
        .cfi_endproc
                                        # -- End function

        .ident  "clang version 5.0.0 (http://llvm.org/git/clang.git
f53edbb006df3bc205bf38008d96de510b2adddd) (http://llvm.org/git/llvm.git
9889fe2290766430b99a2d4fadbc5ba92f8004b6)"
        .section        ".note.GNU-stack","",@progbits
[hjl@gnu-skl-1 pr79793]$

Reply via email to