RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 23 17:14:38 PST 2016
On Tue, Feb 23, 2016 at 8:28 AM, H.J. Lu <hjl.tools at gmail.com> wrote:
> On Tue, Feb 23, 2016 at 8:15 AM, Michael Matz <matz at suse.de> wrote:
>> On Tue, 23 Feb 2016, H.J. Lu wrote:
>>> I thought
>>> An empty type is a type where it and all of its subobjects (recursively)
>>> are of class, structure, union, or array type.
>>> struct empty
>>> empty () = default;
>> Why would that be excluded? There are no subobjects, hence all of them
>> are of class, structure, union or array type, hence this is an empty type.
>> (And that's good, it indeed looks quite empty to me). Even if you would
>> add a non-trivial copy ctor, making this thing not trivially copyable
>> anymore, it would still be empty. Hence, given your proposed language in
>> the psABI, without reference to any other ABI (in particular not to the
>> Itanium C++ ABI), you would then need to pass it without registers. That
>> can't be done, and that's exactly why I find that wording incomplete. It
>> needs implicit references to other languages ABIs to work.
> It is clear to me now. Let's go with
> An empty type is a type where it and all of its subobjects (recursively)
> are of class, structure, union, or array type. No memory slot nor
> register should be used to pass or return an object of empty type that's
> trivially copyable.
> Any comments?
Yes. "trivially copyable" is the wrong restriction. See
http://mentorembedded.github.io/cxx-abi/abi.html#normal-call for the
actual Itanium C++ ABI rule.
It's also completely nonsensical to mention this as a special case in
relation to empty types. The special case applies to all function
parameters, irrespective of whether they're empty -- this rule applies
*long* before you consider whether the type is empty. For instance, in
the x86-64 psABI, this should go right at the start of section 2.2.3
("Parameter Passing and Returning Values"). But please don't add it
there -- it's completely redundant, as section 5.1 already says that
the Itanium C++ ABI is used, so it's not necessary to duplicate rules
More information about the cfe-commits