public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Jason Merrill <jason@redhat.com>, GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: PING^1: [PATCH] Add TYPE_EMPTY_RECORD for C++ empty class
Date: Wed, 09 Dec 2015 14:05:00 -0000	[thread overview]
Message-ID: <CAFiYyc2Qx3DfTraZjUCR0Ha17++SNU-4d5SjGMSWn1hZWKK4uA@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOo9pcJ_75FmUSs62PBf-neM=+-ftqOD=ffpOm7p6Grx7Q@mail.gmail.com>

On Tue, Dec 8, 2015 at 5:22 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Nov 23, 2015 at 12:53 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Mon, Nov 23, 2015 at 1:57 AM, Richard Biener
>> <richard.guenther@gmail.com> wrote:
>>> On Sat, Nov 21, 2015 at 12:46 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> On Fri, Nov 20, 2015 at 2:17 PM, Jason Merrill <jason@redhat.com> wrote:
>>>>> On 11/20/2015 01:52 PM, H.J. Lu wrote:
>>>>>>
>>>>>> On Tue, Nov 17, 2015 at 4:22 AM, Richard Biener
>>>>>> <richard.guenther@gmail.com> wrote:
>>>>>>>
>>>>>>> On Tue, Nov 17, 2015 at 12:01 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>>>>>
>>>>>>>> Empty record should be returned and passed the same way in C and C++.
>>>>>>>> This patch adds LANG_HOOKS_EMPTY_RECORD_P for C++ empty class, which
>>>>>>>> defaults to return false.  For C++, LANG_HOOKS_EMPTY_RECORD_P is defined
>>>>>>>> to is_really_empty_class, which returns true for C++ empty classes.  For
>>>>>>>> LTO, we stream out a bit to indicate if a record is empty and we store
>>>>>>>> it in TYPE_LANG_FLAG_0 when streaming in.  get_ref_base_and_extent is
>>>>>>>> changed to set bitsize to 0 for empty records.  Middle-end and x86
>>>>>>>> backend are updated to ignore empty records for parameter passing and
>>>>>>>> function value return.  Other targets may need similar changes.
>>>>>>>
>>>>>>>
>>>>>>> Please avoid a new langhook for this and instead claim a bit in
>>>>>>> tree_type_common
>>>>>>> like for example restrict_flag (double-check it is unused for
>>>>>>> non-pointers).
>>>>>>
>>>>>>
>>>>>> There is no bit in tree_type_common I can overload.  restrict_flag is
>>>>>> checked for non-pointers to issue an error when it is used on
>>>>>> non-pointers:
>>>>>>
>>>>>>
>>>>>> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/template/qualttp20.C:19:38:
>>>>>> error: ‘__restrict__’ qualifiers cannot be applied to ‘AS::L’
>>>>>>     typedef typename T::L __restrict__ r;// { dg-error "'__restrict__'
>>>>>> qualifiers cannot" "" }
>>>>>
>>>>>
>>>>> The C++ front end only needs to check TYPE_RESTRICT for this purpose on
>>>>> front-end-specific type codes like TEMPLATE_TYPE_PARM; cp_type_quals could
>>>>> handle that specifically if you change TYPE_RESTRICT to only apply to
>>>>> pointers.
>>>>>
>>>>
>>>> restrict_flag is also checked in this case:
>>>>
>>>> [hjl@gnu-6 gcc]$ cat x.i
>>>> struct dummy { };
>>>>
>>>> struct dummy
>>>> foo (struct dummy __restrict__ i)
>>>> {
>>>>   return i;
>>>> }
>>>> [hjl@gnu-6 gcc]$ gcc -S x.i -Wall
>>>> x.i:4:13: error: invalid use of ‘restrict’
>>>>  foo (struct dummy __restrict__ i)
>>>>              ^
>>>> x.i:4:13: error: invalid use of ‘restrict’
>>>> [hjl@gnu-6 gcc]$
>>>>
>>>> restrict_flag can't also be used to indicate `i' is an empty record.
>>>
>>> I'm sure this error can be done during parsing w/o relying on TYPE_RESTRICT.
>>>
>>> But well, use any other free bit (but do not enlarge
>>> tree_type_common).  Eventually
>>> you can free up a bit by putting sth into type_lang_specific currently
>>> using bits
>>> in tree_type_common.
>>
>> There are no bits in tree_type_common I can move.  Instead,
>> this patch overloads side_effects_flag in tree_base.  Tested on
>> Linux/x86-64.  OK for trunk?

I'm fine with using side_effects_flag for this.

I miss an explanation of where this detail of the ABI is documented and wonder
if the term "empty record" is also used in that document and how it is
documented.

Thus

+/* Nonzero in a type considered an empty record.  */
+#define TYPE_EMPTY_RECORD(NODE) \
+  (TYPE_CHECK (NODE)->base.side_effects_flag)

should refer to the ABI where is defined what an "empty record" is and how
it is handled by the backend(s).

+/* Return true if type T is an empty record.  */
+
+static inline bool
+type_is_empty_record_p (const_tree t)
+{
+  return TYPE_EMPTY_RECORD (TYPE_MAIN_VARIANT (t));

the type checker should probably check the bit is consistent across
variants so it can be tested on any of them.

You fail to adjust other targets gimplification hooks which suggests
this is a detail of the x86 psABI and not the C++ ABI?  If so I miss
a -Wpsabi warning for this change.

Did you investigate the effect of this patch on a larger code base?
More specifically does it only affect variadic functions?

An entry for changes.html is warranted as well.

Thanks,
Richard.

>> Thanks.
>>
>> --
>> H.J.
>
>
>
> --
> H.J.

  reply	other threads:[~2015-12-09 14:05 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-08 16:22 H.J. Lu
2015-12-09 14:05 ` Richard Biener [this message]
2015-12-09 18:53   ` H.J. Lu
2015-12-09 21:14     ` H.J. Lu
2015-12-09 21:31     ` Markus Trippelsdorf
2015-12-10 11:24       ` Richard Biener
2015-12-11 23:52         ` H.J. Lu
2015-12-12 14:51           ` Jason Merrill
2015-12-12 15:27             ` Jakub Jelinek
2015-12-12 16:45               ` H.J. Lu
2015-12-12 18:43               ` Marc Glisse
2015-12-14 20:16                 ` Jason Merrill
2015-12-14 20:39                   ` H.J. Lu
2015-12-14 20:44                     ` Jason Merrill
2015-12-14 22:08                       ` H.J. Lu
2016-01-26 19:27                         ` Jason Merrill
2016-01-26 19:52                           ` H.J. Lu
2016-01-26 20:23                             ` Marc Glisse
2016-01-26 20:26                               ` H.J. Lu
2016-01-26 20:44                                 ` Marc Glisse
2016-01-26 21:21                                   ` H.J. Lu
2016-01-26 21:40                                     ` Jakub Jelinek
2016-01-26 22:21                                       ` H.J. Lu
2016-01-27  8:10                                         ` Marc Glisse
2016-01-27  8:21                                           ` Jakub Jelinek
2016-01-27  9:03                                             ` Marc Glisse
2016-01-27 13:46                                               ` H.J. Lu
2016-01-27 15:39                                                 ` H.J. Lu
2016-03-01  1:02                                                   ` Jason Merrill
2016-03-01 22:44                                                     ` H.J. Lu
2016-03-02 16:25                                                       ` Ulrich Weigand
2016-03-02 17:34                                                         ` H.J. Lu
2016-03-15 15:35                                                           ` Jason Merrill
2016-03-15 16:00                                                             ` H.J. Lu
2016-03-15 19:32                                                               ` Jason Merrill
2016-03-16 12:38                                                                 ` H.J. Lu
2016-03-16 16:58                                                                   ` Jason Merrill
2016-03-16 17:02                                                                     ` H.J. Lu
2016-03-16 19:39                                                                       ` H.J. Lu
2016-03-16 19:43                                                                         ` Jason Merrill
2016-03-15 21:40                                                             ` Joseph Myers
2016-03-15 22:31                                                               ` H.J. Lu
2016-03-15 22:35                                                                 ` Joseph Myers
2016-03-16  0:23                                                                   ` H.J. Lu
2016-03-16  0:25                                                                     ` Joseph Myers
2016-03-16  2:17                                                                       ` H.J. Lu
2016-03-16  9:46                                                                         ` Bernhard Reutner-Fischer
2016-03-16 11:53                                                                           ` H.J. Lu
2016-03-16  2:51                                                                       ` Jason Merrill
2016-03-16 11:55                                                                         ` H.J. Lu
2016-03-16 14:33                                                                           ` Jason Merrill
2016-03-16 14:48                                                                             ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFiYyc2Qx3DfTraZjUCR0Ha17++SNU-4d5SjGMSWn1hZWKK4uA@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).