[llvm-bugs] [Bug 26328] New: [x86] Unnecessary copy when taking address of function parameter
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jan 26 13:51:07 PST 2016
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: unassignedbugs at nondot.org
Reporter: hans at chromium.org
CC: llvm-bugs at lists.llvm.org
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 at 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 at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160126/c592f3f6/attachment.html>
More information about the llvm-bugs
mailing list