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

            Bug ID: 26328
           Summary: [x86] Unnecessary copy when taking address of function
                    parameter
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
            Blocks: 26299
    Classification: Unclassified

Consider:

  void f(int*);
  void g(int x) {
    f(&x);
  }

at -Os, Clang generates:

    pushl    %eax
    movl    8(%esp), %eax
    movl    %eax, (%esp)
    leal    (%esp), %eax
    pushl    %eax
    calll    "?f@@YAXPAH@Z"
    addl    $4, %esp
    popl    %eax
    retl

MSVC generates:

  00000000: 8D 44 24 04        lea         eax,[esp+4]
  00000004: 50                 push        eax
  00000005: E8 00 00 00 00     call        ?f@@YAXPAH@Z
  0000000A: 59                 pop         ecx
  0000000B: C3                 ret


It seems Clang is wasting two instructions copying x to g's stack frame,
whereas MSVC just uses the address of the parameter directly.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to