[llvm-bugs] [Bug 26830] New: misaligned placement of function arguments of over-aligned type on the stack (ABI incompatibility)

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 3 05:13:28 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26830

            Bug ID: 26830
           Summary: misaligned placement of function arguments of
                    over-aligned type on the stack (ABI incompatibility)
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kretz at kde.org
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Testcase:
#include <xmmintrin.h>
struct X { __m128 x; };
X f(X a, X b) { return {_mm_add_ps(a.x, b.x)}; }

Compiles to (-msse -m32 -O2):
00000000 <f(X, X)>:
   0:·       mov    0x4(%esp),%eax
   4:·       movups 0x8(%esp),%xmm0
   9:·       movups 0x18(%esp),%xmm1
   e:·       addps  %xmm0,%xmm1
  11:·       movaps %xmm1,(%eax)
  14:·       ret    $0x4

This is incorrect according to the x86 psABI document, which states that
padding must be added so that the placement of the argument matches its
alignment. GCC compiles the code to:
00000000 <f(X, X)>:
   0:·       movaps 0x24(%esp),%xmm0
   5:·       mov    0x4(%esp),%eax
   9:·       addps  0x14(%esp),%xmm0
   e:·       movaps %xmm0,(%eax)
  11:·       ret    $0x4

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160303/4be17de1/attachment.html>


More information about the llvm-bugs mailing list