[LLVMbugs] [Bug 21510] New: X86-32: Clang passes fewer vectors in SSE registers than GCC

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Nov 6 16:54:47 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=21510

            Bug ID: 21510
           Summary: X86-32: Clang passes fewer vectors in SSE registers
                    than GCC
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: rnk at google.com
                CC: grosbach at apple.com, llvmbugs at cs.uiuc.edu,
                    paul_robinson at playstation.sony.com,
                    rafael.espindola at gmail.com, rjmccall at apple.com
    Classification: Unclassified

Clang's 32-bit x86 calling convention rules only pass 4 vectors in registers:

def CC_X86_32_Common : CallingConv<[
...
  // The first 4 SSE vector arguments are passed in XMM registers.
  CCIfNotVarArg<CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
                CCAssignToReg<[XMM0, XMM1, XMM2, XMM3]>>>,

  // The first 4 AVX 256-bit vector arguments are passed in YMM registers.
  CCIfNotVarArg<CCIfType<[v32i8, v16i16, v8i32, v4i64, v8f32, v4f64],
                CCIfSubtarget<"hasFp256()",
                CCAssignToReg<[YMM0, YMM1, YMM2, YMM3]>>>>,
...

GCC will use all of XMM0-XMM7 to pass arguments, so Clang is ABI incompatible.

It looks like Clang was trying to match gcc's behavior with -msseregparm, which
is documented to only use the first four XMM registers for floating point
arguments. However, for true vector arguments (not float / double), gcc
currently uses up to eight registers.

So, are we broken here? If so, can we fix it, or are users relying heavily on
our x86_32 ABI stability? Can we fix the problem for YMM and ZMM registers at
least? Should we make this conditional on OS to make clang backwards compatible
with itself on Mac, BSD, etc, and compatible with the dominant system compiler
(GCC) on Linux?

-- 
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/20141107/570b558c/attachment.html>


More information about the llvm-bugs mailing list