[llvm-dev] Clang generating unnecessary spills(?) when passing a struct argument by value
Riyaz Puthiyapurayil via llvm-dev
llvm-dev at lists.llvm.org
Sun Jul 19 21:59:52 PDT 2020
Adding an 8-byte alignment to `blah` makes those two pairs of movq and movaps go away. But I don't know why the alignment matters in this case.
From: Riyaz Puthiyapurayil
Sent: Sunday, July 19, 2020 7:47 PM
To: llvm-dev <llvm-dev at lists.llvm.org>
Subject: Clang generating unnecessary spills(?) when passing a struct argument by value
// Test case:
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);
}
// Generated code (Clang -O3) - trunk, 10.0.0 (https://godbolt.org/):
boo: # @boo
subq $56, %rsp
movq blah+16(%rip), %rax
movq %rax, 48(%rsp)
movups blah(%rip), %xmm0
movaps %xmm0, 32(%rsp)
movq 48(%rsp), %rax
movq %rax, 16(%rsp)
movaps 32(%rsp), %xmm0
movups %xmm0, (%rsp)
callq foo
addq $56, %rsp
retq
// Generated code (gcc -O3) - 7.3.0 (https://godbolt.org/):
boo:
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
Why is clang generating all those instructions (which seem to be just unnecessary spills of the registers: %rax and %xmm0)?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200720/6ef9dd37/attachment.html>
More information about the llvm-dev
mailing list