[LLVMbugs] [Bug 9794] New: extra copy when passing struct by value

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 25 13:46:33 PDT 2011


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

           Summary: extra copy when passing struct by value
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: jmuizelaar at mozilla.com
                CC: llvmbugs at cs.uiuc.edu


struct p
{
        int a;
        int b;
        int c;
        int d;
        int e;
        int f;
        int g;
        int h;
        int i;
        int j;
        int k;
        int l;
};

int g(struct p q);

int f(struct p q) {
        return g(q);
}


The following code is generated by clang:

_f:                                     ## @f
        pushq   %rbp
        movq    %rsp, %rbp
        subq    $96, %rsp
        movaps  16(%rbp), %xmm0
        movaps  32(%rbp), %xmm1
        movaps  48(%rbp), %xmm2
        movaps  %xmm2, -16(%rbp)
        movaps  %xmm1, -32(%rbp)
        movaps  %xmm0, -48(%rbp)
        movq    -16(%rbp), %rax
        movq    -8(%rbp), %rcx
        movq    %rcx, 40(%rsp)
        movq    %rax, 32(%rsp)
        movq    -24(%rbp), %rax
        movq    %rax, 24(%rsp)
        movq    -32(%rbp), %rax
        movq    %rax, 16(%rsp)
        movq    -48(%rbp), %rax
        movq    -40(%rbp), %rcx
        movq    %rcx, 8(%rsp)
        movq    %rax, (%rsp)
        callq   _g
        addq    $96, %rsp
        popq    %rbp
        ret


gcc-4.2 gives:

.globl _f
_f:
        pushq   %rbp
        movq    %rsp, %rbp
        leave
        jmp     _g

-- 
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.



More information about the llvm-bugs mailing list