On 3/5/19 3:40 PM, Jakub Jelinek wrote: > On Tue, Mar 05, 2019 at 05:33:45PM -0500, Jason Merrill wrote: >> The x86_64 psABI says that an empty class isn't passed or returned in memory >> or registers, so we shouldn't set %eax in this function. This seems like a >> missed case from the GCC 8 TYPE_EMPTY_P changes. >> >> Shall I apply this for GCC 9, or hold it for stage 1? >> >> * function.c (expand_function_end): Don't copy a TYPE_EMPTY_P >> result. > > I'd go for it now. See below for a testsuite nit: Agreed.
> >> --- /dev/null >> +++ b/gcc/testsuite/g++.dg/opt/empty3.C >> @@ -0,0 +1,8 @@ >> +// PR c++/88529 >> +// { dg-do compile { target c++11 } } >> +// { dg-final { scan-assembler-not mov { target x86_64-*-* } } } > > But this probably needs to be { target { { i?86-*-* x86_64-*-* } && { ! { > ia32 } } } } > or similar instead, so that it is done for x86_64 -m64 and -mx32, but not > -m32. > >> +// The x86_64 psABI says that f() doesn't put the return value anywhere. >> + >> +class A{}; >> + >> +A f() { return {}; } > > Jakub >