[LLVMbugs] [Bug 9447] New: Adding a copy constructor that is the same as the default generates worse code
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Mar 9 20:17:14 PST 2011
http://llvm.org/bugs/show_bug.cgi?id=9447
Summary: Adding a copy constructor that is the same as the
default generates worse code
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 point
{
double x, y;
point(double x, double y) : x(x), y(y) {}
point(const point& p) : x(p.x), y(p.y) {}
};
void get_point(void *c, double *x, double *y);
class c {
int count;
void *p;
point getPoint();
};
point c::getPoint(){
double x, y;
get_point(p, &x, &y);
return point(x, y);
}
Compiles to:
_ZN1c8getPointEv: # @_ZN1c8getPointEv
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
movq 8(%rdi), %rdi
leaq -8(%rbp), %rsi
leaq -16(%rbp), %rdx
callq _Z9get_pointPvPdS0_
movsd -8(%rbp), %xmm0
movsd -16(%rbp), %xmm1
addq $16, %rsp
popq %rbp
ret
With the copy-constructor commented out we get:
_ZN1c8getPointEv: # @_ZN1c8getPointEv
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $24, %rsp
movq %rdi, %rbx
movq 8(%rsi), %rdi
leaq -16(%rbp), %rsi
leaq -24(%rbp), %rdx
callq _Z9get_pointPvPdS0_
movsd -24(%rbp), %xmm0
movsd -16(%rbp), %xmm1
movsd %xmm1, (%rbx)
movsd %xmm0, 8(%rbx)
movq %rbx, %rax
addq $24, %rsp
popq %rbx
popq %rbp
ret
--
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