From patchwork Tue Jun 13 13:20:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 775162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wn9PN28N8z9s81 for ; Tue, 13 Jun 2017 23:20:40 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="aLTahfby"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; q=dns; s= default; b=dyDVmkwqFzMpoPROtlP0S1pON0IaSCKrrgbk5WAncyv4s2K2UXnMO fT8Cn9PDo8oIOnIKH0DW52/gZYSikEdupgJGnS1/Yb/A3dwSat/j07S2ObTK7RR1 hfNsWZeCuiSeG8vJFpSZl76WWIoFKL/+vW1s9xzQuvKwOdVClycCzo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; s= default; bh=HrguJuakRbkzIMiE4lWWiOv7tZ0=; b=aLTahfbyQfCtpe7OjtVF svqvraX9hcLVzS4M1GmE/osBrrGChCZdSI+KGQehPdzjC7ePDE1cCcOvzzrqRa5S AK7iLAckiDlwyKet3Ja/oZqyoJ4fiqPx1ppe+FU02WdlAL8tFM1i8Hj7Te8FcTE/ VTzy9m0OYdW+yuVj/WMEu/I= Received: (qmail 42174 invoked by alias); 13 Jun 2017 13:20:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 42069 invoked by uid 89); 13 Jun 2017 13:20:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-ot0-f193.google.com Received: from mail-ot0-f193.google.com (HELO mail-ot0-f193.google.com) (74.125.82.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Jun 2017 13:20:03 +0000 Received: by mail-ot0-f193.google.com with SMTP id t31so14193179ota.2 for ; Tue, 13 Jun 2017 06:20:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=PdHnMyH6yKOGRvx3vqPMynpcoZ/lU6YjzRNTsDtkU3o=; b=gojtu1NUCNsi00du1jKLNDaLMskxEKLcUQK2kQh2RQY381W4IxklgAFqb9Mi/dx/rk GOxm0IBs625rEd73IZcAuUlt4byTw/R9rX3pSniBUpv33yg2FKSjbcVsCWmhNcx3B41f ve17xfdOLGu2i7/asgEm+Ogv9xrLULq2HsecmsAubhrChgDbT9H6Cy63BQQgj47rNHw8 7QPrQtWkNoAHWbIQF1L6eo5WdSuAyzi21m57fcsll8pyEXrF5EHPahBquQ66SMyfcRIY tnMANYGoyZiSf/qGMBZ3GRchXVRCDyHWlUj+OAiDU9e1FUO0UOTTnxOajMVCT5GS//j/ JuZw== X-Gm-Message-State: AODbwcCD1V9JK+sB8Ar93Sp1qdZuxndOJ9DObVRSL8F4Rg092f6gCMFA AQBXULlyZiHO7nz5kukLNV6/d/N3SQ== X-Received: by 10.157.49.3 with SMTP id e3mr31286652otc.254.1497360006648; Tue, 13 Jun 2017 06:20:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.36.8 with HTTP; Tue, 13 Jun 2017 06:20:05 -0700 (PDT) In-Reply-To: References: From: Richard Biener Date: Tue, 13 Jun 2017 15:20:05 +0200 Message-ID: Subject: Re: [PATCH][RFC] Canonize names of attributes. To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: GCC Patches X-IsSubscribed: yes On Tue, Jun 13, 2017 at 2:32 PM, Martin Liška 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 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 > > * parser.c (cp_parser_gnu_attribute_list): Canonize attribute > names. > (cp_parser_std_attribute): Likewise. > > gcc/go/ChangeLog: > > 2017-06-09 Martin Liska > > * go-gcc.cc (Gcc_backend::function): Use no_split_stack > instead of __no_split_stack__. > > gcc/c/ChangeLog: > > 2017-06-09 Martin Liska > > * c-parser.c (c_parser_attributes): Canonize attribute names. > > gcc/c-family/ChangeLog: > > 2017-06-09 Martin Liska > > * 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 > > * 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 > > * 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(-) > > 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