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

           Summary: [x86-64 ABI] struct passed partially in registers if
                    there's an sret parameter
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: ABI
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


Created an attachment (id=3013)
 --> (http://llvm.org/bugs/attachment.cgi?id=3013)
The code in question

There's an ABI bug in llvm-gcc for x86-64 linux.
The attached code should generate functionally identical asm for both
functions, and does so with stock g++ (version: Ubuntu 4.3.2-1ubuntu12) but not
with llvm-g++; it generates incorrect code for fail().

The issue seems to be that the sret pointer isn't taken into account when the
number of available integer registers for the struct parameter is calculated
causing that parameter to be passed with one half in a register and one in
memory (in violation of the ABI spec, which requires it to be passed entirely
in memory if it does not fit entirely into registers).

g++ output (via objdump)
----
0000000000000000 <fail>:
   0:   48 8b 44 24 08          mov    0x8(%rsp),%rax
   5:   4c 89 4f 10             mov    %r9,0x10(%rdi)
   9:   48 89 07                mov    %rax,(%rdi)
   c:   48 8b 44 24 10          mov    0x10(%rsp),%rax
  11:   48 89 47 08             mov    %rax,0x8(%rdi)
  15:   48 89 f8                mov    %rdi,%rax
  18:   c3                      retq   
----

llvm-g++ output:
----
0000000000000000 <fail>:
   0:   48 89 f8                mov    %rdi,%rax
   3:   4c 89 0f                mov    %r9,(%rdi)
   6:   48 8b 4c 24 08          mov    0x8(%rsp),%rcx
   b:   48 89 4f 08             mov    %rcx,0x8(%rdi)
   f:   48 8b 4c 24 10          mov    0x10(%rsp),%rcx
  14:   48 89 4f 10             mov    %rcx,0x10(%rdi)
  18:   c3                      retq   
----


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to