public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: "Martin Liška" <mliska@suse.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH][RFC] Canonize names of attributes.
Date: Tue, 13 Jun 2017 13:20:00 -0000	[thread overview]
Message-ID: <CAFiYyc0P8sfD8V79aWYnzZqTaumVXAFgn7YZpzXe+9ZnN6Kv+A@mail.gmail.com> (raw)
In-Reply-To: <d34360a3-c245-7525-03e7-99a9ba8830e6@suse.cz>

On Tue, Jun 13, 2017 at 2:32 PM, Martin Liška <mliska@suse.cz> wrote:
> Hello.
>
> After some discussions with Richi, I would like to propose patch that will
> come up with a canonical name of attribute names. That means __attribute__((__abi_tag__))
> will be given 'abi_tag' as IDENTIFIER_NAME of the attribute. The change can improve
> attribute name lookup and we can delete all the ugly code that compares strlen(i1)
> == strlen(i2) + 4, etc.
>
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests (w/ default
> languages). I'm currently testing objc, obj-c++ and go.
>
> Ready to be installed?


+tree
+canonize_attr_name (tree attr_name)
+{

needs a comment.

+  if (l > 4 && s[0] == '_')
+    {
+      gcc_assert (s[1] == '_');
+      gcc_assert (s[l - 2] == '_');
+      gcc_assert (s[l - 1] == '_');
+      return get_identifier_with_length (s + 2, l - 4);
+    }

a single gcc_checking_assert please.  I think this belongs in attribs.[ch].

Seeing

diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c
index e1c8bdff986..6d0e9279ed6 100644
--- a/gcc/c-family/c-lex.c
+++ b/gcc/c-family/c-lex.c
@@ -316,6 +316,7 @@ c_common_has_attribute (cpp_reader *pfile)
     {
       attr_name = get_identifier ((const char *)
                                  cpp_token_as_text (pfile, token));
+      attr_name = canonize_attr_name (attr_name);

I wondered if we can save allocating the non-canonical identifier.  Like
with

tree
canonize_attr_name (const char *attr_name, size_t len)

as we can pass it IDENTIFIER_POINTER/LENGTH or the token.  OTOH
all other cases do have IDENTIFIERs already...

@ -24638,6 +24639,11 @@ cp_parser_gnu_attribute_list (cp_parser* parser)
              else
                {
                  arguments = build_tree_list_vec (vec);
+                 tree tv;
+                 if (arguments != NULL_TREE
+                     && ((tv = TREE_VALUE (arguments)) != NULL_TREE)
+                     && TREE_CODE (tv) == IDENTIFIER_NODE)
+                     TREE_VALUE (arguments) = canonize_attr_name (tv);
                  release_tree_vector (vec);
                }

are you sure this is needed?  This seems to be solely arguments to
attributes.

The rest of the changes look good but please wait for input from FE maintainers.

Thanks,
Richard.

> Martin
>
>
> gcc/cp/ChangeLog:
>
> 2017-06-09  Martin Liska  <mliska@suse.cz>
>
>         * parser.c (cp_parser_gnu_attribute_list): Canonize attribute
>         names.
>         (cp_parser_std_attribute): Likewise.
>
> gcc/go/ChangeLog:
>
> 2017-06-09  Martin Liska  <mliska@suse.cz>
>
>         * go-gcc.cc (Gcc_backend::function): Use no_split_stack
>         instead of __no_split_stack__.
>
> gcc/c/ChangeLog:
>
> 2017-06-09  Martin Liska  <mliska@suse.cz>
>
>         * c-parser.c (c_parser_attributes): Canonize attribute names.
>
> gcc/c-family/ChangeLog:
>
> 2017-06-09  Martin Liska  <mliska@suse.cz>
>
>         * c-format.c (cmp_attribs): Simplify comparison of attributes.
>         * c-lex.c (c_common_has_attribute): Canonize attribute names.
>
> gcc/ChangeLog:
>
> 2017-06-09  Martin Liska  <mliska@suse.cz>
>
>         * tree.c (cmp_attrib_identifiers): Simplify comparison of attributes.
>         (private_is_attribute_p): Likewise.
>         (private_lookup_attribute): Likewise.
>         (private_lookup_attribute_by_prefix): Likewise.
>         (remove_attribute): Likewise.
>         (canonize_attr_name): New function.
>         * tree.h: Declared here.
>
> gcc/testsuite/ChangeLog:
>
> 2017-06-09  Martin Liska  <mliska@suse.cz>
>
>         * g++.dg/cpp0x/pr65558.C: Change expected warning.
>         * gcc.dg/parm-impl-decl-1.c: Likewise.
>         * gcc.dg/parm-impl-decl-3.c: Likewise.
> ---
>  gcc/c-family/c-format.c                 |  13 ++--
>  gcc/c-family/c-lex.c                    |   1 +
>  gcc/c/c-parser.c                        |   9 +++
>  gcc/cp/parser.c                         |  11 +++-
>  gcc/go/go-gcc.cc                        |   2 +-
>  gcc/testsuite/g++.dg/cpp0x/pr65558.C    |   2 +-
>  gcc/testsuite/gcc.dg/parm-impl-decl-1.c |   2 +-
>  gcc/testsuite/gcc.dg/parm-impl-decl-3.c |   2 +-
>  gcc/tree.c                              | 108 +++++++++++---------------------
>  gcc/tree.h                              |   4 ++
>  10 files changed, 69 insertions(+), 85 deletions(-)
>
>

  reply	other threads:[~2017-06-13 13:20 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13 12:32 Martin Liška
2017-06-13 13:20 ` Richard Biener [this message]
2017-06-14  7:48   ` Martin Liška
2017-06-14  9:07     ` Richard Biener
2017-06-14 11:03       ` Martin Liška
2017-06-14 11:19         ` Richard Biener
2017-06-14 16:40       ` Joseph Myers
2017-06-28 14:45         ` Martin Liška
2017-06-14 17:24 ` Jason Merrill
2017-06-16  0:07   ` Martin Sebor
2017-06-28 14:46   ` Martin Liška
2017-06-28 16:06     ` Joseph Myers
2017-06-28 19:01       ` Jason Merrill
2017-06-30  9:23         ` [PATCH v2][RFC] " Martin Liška
2017-06-30 19:35           ` Jason Merrill
2017-07-03  9:52             ` Martin Liška
2017-07-03 21:00               ` Jason Merrill
2017-07-11 13:38                 ` Martin Liška
2017-07-11 15:52                   ` Jason Merrill
2017-07-13 13:48                     ` Martin Liška
2017-07-13 13:51                       ` [RFC][PATCH] Do refactoring of attribute functions and move them to attribs.[hc] Martin Liška
2017-07-14  7:23                         ` Jeff Law
2017-07-14  7:40                           ` Martin Liška
2017-08-04 13:53                           ` Martin Liška
2017-08-08  4:37                             ` Martin Liška
2017-08-08  9:14                               ` Tom de Vries
2017-09-12  7:55                         ` Jakub Jelinek
2017-09-12 11:31                           ` Martin Liška
2017-09-12 11:40                             ` Jakub Jelinek
2017-09-12 14:25                               ` Martin Liška
2017-07-27 12:57                       ` [PATCH v2][RFC] Canonize names of attributes Martin Liška
2017-08-02 11:25                       ` Joseph Myers
2017-08-04 13:43                         ` Martin Liška
2017-08-04 16:54                           ` Jason Merrill
2017-08-07 16:44                             ` [PATCH][OBVIOUS] Fix missing include of header file in mips.c Martin Liška
2017-08-07 17:10                               ` [PATCH][OBVIOUS] Add missing header file attribs.h to couple of targets Martin Liška
2017-08-02 19:42                       ` [PATCH v2][RFC] Canonize names of attributes Jason Merrill

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=CAFiYyc0P8sfD8V79aWYnzZqTaumVXAFgn7YZpzXe+9ZnN6Kv+A@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    /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).