http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
Chip Salzenberg <chip at pobox dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |chip at pobox dot com --- Comment #15 from Chip Salzenberg <chip at pobox dot com> 2012-08-06 00:37:36 UTC --- Ping. I've just run into this with the tip of the gcc 4.7.1 branch. Is there a workaround? Some way to label the struct as not needing to be stored? Something like __attribute__((noaddress)); We want to pass and return structs by value as current C++ style recommends, but the extra register spills are dragging down performance. For small key classes we've switched to using big integers with masking functions, but for larger ones there is no workaround that we know of. Given this code: extern val_t foo(); extern int bar(val_t); int main() { return bar(foo()); } When val_t is a struct of two int64_t on x86_64, the code has two extra stores: > movq %rax, (%rsp) > movq %rdx, 8(%rsp) and the stack frame is larger and there is no tail call optimization. When val_t is __int128 on x86_64, the code is optimal: tail call, no extra stores, smaller stack frame (because there is no need to store the value).