This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: C++ PATCH to adjust empty class parameter passing ABI
- From: Ramana Radhakrishnan <ramana dot gcc at googlemail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Kyrill Tkachov <kyrylo dot tkachov at foss dot arm dot com>, Christophe Lyon <christophe dot lyon at linaro dot org>, Jason Merrill <jason at redhat dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>, Jonathan Wakely <jwakely at redhat dot com>, "H.J. Lu" <hjl dot tools at gmail dot com>, Richard Earnshaw <Richard dot Earnshaw at arm dot com>
- Date: Thu, 14 Apr 2016 12:19:26 +0100
- Subject: Re: RFC: C++ PATCH to adjust empty class parameter passing ABI
- Authentication-results: sourceware.org; auth=none
- References: <570D5A44 dot 6060105 at redhat dot com> <20160413153217 dot GT19207 at tucnak dot redhat dot com> <570E6B9B dot 1010200 at redhat dot com> <570E99E6 dot 3040603 at redhat dot com> <20160413191830 dot GW19207 at tucnak dot redhat dot com> <570EA818 dot 9030807 at redhat dot com> <CAKdteOa-ztXv9+fE5Jd26XXeKZnwAwPgcgA7PCPH6xaS0_vNiA at mail dot gmail dot com> <570F65BD dot 6030204 at foss dot arm dot com> <CAJA7tRZ-cHhufp+-tYz8gqmKvkkKZ-MRnDBgz7auhnthw8dDEQ at mail dot gmail dot com> <20160414103616 dot GB19207 at tucnak dot redhat dot com>
On Thu, Apr 14, 2016 at 11:36 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Apr 14, 2016 at 11:25:07AM +0100, Ramana Radhakrishnan wrote:
>> > I see the test failing on aarch64-none-linux-gnu (native)
>> > with no output, just:
>> > spawn [open ...]
>> > FAIL: g++.dg/abi/empty13.C -std=gnu++98 execution test
>> >
>> > And I see it passing on aarch64-none-elf.
>>
I don't understand why this passes on aarch64-none-elf btw.
>> IIRC on AArch64 we document that empty classes and structs take up a
>> slot as per the PCS .
>>
>> http://infocenter.arm.com/help/topic/com.arm.doc.ihi0059b/IHI0059B_cppabi64.pdf
>>
>> See section 3.1
>>
>> For the purposes of parameter passing in
>> [
>> AAPCS64
>> ], a parameter whose type is an empty class shall be treated as if its
>> type were an aggregate with a
>> single
>> member of type unsigned byte.
>
> One thing is passing such arguments in registers, another is how they are
> passed on the stack (e.g. if there are several other arguments that are
> passed in registers).
It would just be treated like a structure with an unsigned byte and
treated the same way for parameter passing on the stack - i.e. IIRC
take a slot of 8 bytes.
> Also, note that the (new) definition of C++ empty class I believe includes
> even empty classes that are normally very large, i.e. don't pretend they
> are just single byte, but can be e.g. 1024 bytes or longer.
> Do you want to still pass them in registers and/or on the stack as if
> it is 1 byte, 0 bytes or more bytes?
I don't know off-hand.
Is this a valid example for what you have in mind ?
struct baz
{
char a[1024];
};
struct foo : baz
{
};
int bar (struct foo b, int x)
if so, that would get treated as though it is just a 1 byte quantity
for C++. as per current behaviour by both gcc and llvm for aarch64.
> How do you pass empty C structures?
I don't think we do anything special for empty C structures which IIRC
means they don't take a slot.
>
> E.g. looking at sparc-solaris2.12 cross, C for empty structures passes
> both in registers and on the stack as if there is one argument (and C++ did
> too for the empty classes that pretended to have size 1), so appart from the
> ICE in emit_move_insn there is no ABI change, only perhaps for the larger
> structs.
>
> Guess we need to figure out what do the various targets do for C empty
> structures and decide what we do want to do with C++ empty classes.
> Perhaps the C++ FE should just set some flag on the empty class parameters,
> and let the backends decide what to do with those.
Ramana
>
> Jakub