[PATCH] D61224: Fix i386 stack alignment for parameter type with breakdowns

Wei Xiao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 07:28:05 PDT 2019


wxiao3 added a comment.

No, in most normal operation for x86_32, LLVM does the wrong thing. A simple example to show the ABI bug:

  $ cat test.c
  void callee(int, __float128);
  void caller() {
    callee(1, 2.q);
  }
  $ $ clang -m32 -S test.c -o -
  caller:                                 # @caller
  # %bb.0:                                # %entry
          pushl   %ebp
          movl    %esp, %ebp
          subl    $24, %esp
          movl    %esp, %eax
          movl    $1073741824, 16(%eax)   # imm = 0x40000000
          movl    $0, 12(%eax)
          movl    $0, 8(%eax)
          movl    $0, 4(%eax)
          movl    $1, (%eax)
          calll   callee
          addl    $24, %esp
          popl    %ebp
          retl
  
  $ gcc -m32 -S test.c -o -
  caller:
  .LFB0:
          .cfi_startproc
          pushl   %ebp
          .cfi_def_cfa_offset 8
          .cfi_offset 5, -8
          movl    %esp, %ebp
          .cfi_def_cfa_register 5
          subl    $8, %esp
          subl    $16, %esp
          movl    $0, (%esp)
          movl    $0, 4(%esp)
          movl    $0, 8(%esp)
          movl    $1073741824, 12(%esp)
          subl    $12, %esp
          pushl   $1
          call    callee
          addl    $32, %esp
          nop
          leave

For 32bit, float128 is always passed by memory even with sse/avx2/avx512 enabled.
And float128 is broken to 4xi32 for x86_32.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61224/new/

https://reviews.llvm.org/D61224





More information about the llvm-commits mailing list