https://bugs.llvm.org/show_bug.cgi?id=46798
Bug ID: 46798
Summary: Unnecessary spills when passing a struct argument by
value
Product: libraries
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: unassignedb...@nondot.org
Reporter: ri...@synopsys.com
CC: craig.top...@gmail.com, llvm-bugs@lists.llvm.org,
llvm-...@redking.me.uk, spatel+l...@rotateright.com
Created attachment 23763
--> https://bugs.llvm.org/attachment.cgi?id=23763&action=edit
C test case to reproduce the problem
Clang generates unnecessary spills of %xmm0 and %rax for the attached test
case. See below (and attached test) for details.
The issue goes away if an __attribute__((align(8)) is added to the variable
blah.
// Test case:
// compile: clang -O3 -S -emit-llvm -o test.s test.c
typedef struct { int a; int b; int c; int d; int e; int f; } T;
extern int foo(T a);
extern T blah;
int boo() {
return foo(blah);
}
Code generated by gcc:
subq $40, %rsp
movq blah+16(%rip), %rax
movdqu blah(%rip), %xmm0
movq %rax, 16(%rsp)
movups %xmm0, (%rsp)
call foo
addq $40, %rsp
ret
Code generated by "clang -O3"
subq $56, %rsp
movq blah+16(%rip), %rax
movq %rax, 48(%rsp) ; unnecessary
movups blah(%rip), %xmm0
movaps %xmm0, 32(%rsp) ; unnecessary
movq 48(%rsp), %rax ; unnecessary
movq %rax, 16(%rsp)
movaps 32(%rsp), %xmm0 ; unnecessary
movups %xmm0, (%rsp)
callq foo
addq $56, %rsp
retq
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs