<div dir="ltr"><div dir="ltr">On Wed, 16 Jan 2019 at 16:20, John McCall via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 16 Jan 2019, at 18:32, Richard Smith wrote:<br>
<br>
> On Wed, 16 Jan 2019 at 09:10, John McCall via cfe-commits <<br>
> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br>
><br>
>> On 16 Jan 2019, at 9:13, Aaron Ballman wrote:<br>
>><br>
>>> On Wed, Jan 16, 2019 at 1:57 AM Akira Hatanaka <<a href="mailto:ahatanaka@apple.com" target="_blank">ahatanaka@apple.com</a>><br>
>>> wrote:<br>
>>>><br>
>>>> Yes, the behavior of the compiler doesn’t match what’s explained<br>
>>>> in the documentation anymore.<br>
>>>><br>
>>>> Please take a look at the attached patch, which updates the<br>
>>>> documentation.<br>
>>><br>
>>> Patch mostly LGTM, but I did have one wording suggestion.<br>
>>><br>
>>>> diff --git a/include/clang/Basic/AttrDocs.td<br>
>>>> b/include/clang/Basic/AttrDocs.td<br>
>>>> index 5773a92c9c..ca3cfcf9b2 100644<br>
>>>> --- a/include/clang/Basic/AttrDocs.td<br>
>>>> +++ b/include/clang/Basic/AttrDocs.td<br>
>>>> @@ -2478,15 +2478,20 @@ def TrivialABIDocs : Documentation {<br>
>>>>    let Category = DocCatVariable;<br>
>>>>    let Content = [{<br>
>>>>  The ``trivial_abi`` attribute can be applied to a C++ class, struct,<br>
>>>> or union.<br>
>>>> -It instructs the compiler to pass and return the type using the C<br>
>>>> ABI for the<br>
>>>> +``trivial_abi`` has the following effects:<br>
>>>> +<br>
>>>> +- It instructs the compiler to pass and return the type using the C<br>
>>>> ABI for the<br>
>>>>  underlying type when the type would otherwise be considered<br>
>>>> non-trivial for the<br>
>>>>  purpose of calls.<br>
>>>> -A class annotated with `trivial_abi` can have non-trivial<br>
>>>> destructors or copy/move constructors without automatically becoming<br>
>>>> non-trivial for the purposes of calls. For example:<br>
>>>> +- It makes the destructor and copy and move constructors of the<br>
>>>> class trivial<br>
>>>> +that would otherwise be considered non-trivial under the C++ ABI<br>
>>>> rules.<br>
>>><br>
>>> How about: It makes the destructor, copy constructors, and move<br>
>>> constructors of the class trivial even if they would otherwise be<br>
>>> non-trivial under the C++ ABI rules.<br>
>><br>
>> Let's not say that it makes them trivial, because it doesn't.  It causes<br>
>> their immediate non-triviality to be ignored for the purposes of<br>
>> deciding<br>
>> whether the type can be passed in registers.<br>
>><br>
><br>
> Given the attribute now forces the type to be passed in registers, I think<br>
> it'd be more to the point to say that it makes the triviality of those<br>
> special members be ignored when deciding whether to pass a type with a<br>
> subobject of this type in registers.<br>
<br>
Wait, it forces it to be passed in registers?  I thought the design<br>
was that it didn't override the non-trivial-abi-ness of subobjects;<br>
see all the discussion of trivially_relocatable.<br></blockquote><div><br></div><div>The attribute is ill-formed if applied to a class that has a subobject that can't be passed in registers (or that has a vptr). And then as a weird special case we don't instantiate the attribute when instantiating a class if it would be ill-formed (well, we instantiate it and then remove it again, but the effect is the same).</div><div><br></div><div>The commit at the start of this email chain switches us from the "just override the trivialness for the purposes of the ABI" model to /also/ forcing the type to be passed in registers (the type would otherwise not be passed in registers in some corner cases, such as if all its copy/move special members are deleted).</div></div></div>