From patchwork Thu Oct 11 11:48:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 982443 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-487317-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="u/uT32Sb"; dkim-atps=neutral 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 42W8Q113ySz9s47 for ; Thu, 11 Oct 2018 22:49:11 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=F583D2CtBWW6SptIX5imAq9XhyDPAlZ0Y2DoL+dIL5opq7rcTu hbtFgUVCBLp8lmKOrCgCPJOtkisckLRQPnRGP+pvk7KIIhml/FoTsgHLcRWM7eRE zAaH3IBEUKtnPMHCebQa5coJUbqAQrtAX9SQoS7GgdoIbdwYlDtltV+YA= 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:from :subject:to:cc:message-id:date:mime-version:content-type; s= default; bh=YvFAwoxI06EXEK1iqUId8gl3pmE=; b=u/uT32SbQl8wQrggk8vP BfFXvO6vsDircEjH0C6pqCMlaxu7VKePUB6RieSioARt9G4nXkSG20knSBah/2Zy 4FXCF3M/caNZ6wjxyADm3EnenD7B2+8VuEAAW/XEa6/lIIL0boSk3KuMtixdSQfo yQGokcgJXdGL7qQaSWg9WN8= Received: (qmail 60115 invoked by alias); 11 Oct 2018 11:49:01 -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 59994 invoked by uid 89); 11 Oct 2018 11:48:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=icf, Ready, Based X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Oct 2018 11:48:49 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F2F8DACAD; Thu, 11 Oct 2018 11:48:34 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Simplify comparison of attrs in IPA ICF. To: gcc-patches@gcc.gnu.org Cc: Jan Hubicka Message-ID: Date: Thu, 11 Oct 2018 13:48:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi. This is simplification in ICF where we can use attribute comparison function from attrs.c instead of implementing our own. Patch survives tests on x86_64-linux-gnu. Ready for trunk? Thanks, Martin gcc/ChangeLog: 2018-10-10 Martin Liska * ipa-icf.c (sem_item::compare_attributes): Remove. (sem_item::compare_referenced_symbol_properties): Use attribute_list_equal instead. (sem_function::equals_wpa): Likewise. * ipa-icf.h: Remove compare_attributes. --- gcc/ipa-icf.c | 59 ++++----------------------------------------------- gcc/ipa-icf.h | 3 --- 2 files changed, 4 insertions(+), 58 deletions(-) diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index 3c54f8d4b6d..ff313197f64 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -305,57 +305,6 @@ sem_function::get_hash (void) return m_hash; } -/* Return ture if A1 and A2 represent equivalent function attribute lists. - Based on comp_type_attributes. */ - -bool -sem_item::compare_attributes (const_tree a1, const_tree a2) -{ - const_tree a; - if (a1 == a2) - return true; - for (a = a1; a != NULL_TREE; a = TREE_CHAIN (a)) - { - const struct attribute_spec *as; - const_tree attr; - - as = lookup_attribute_spec (get_attribute_name (a)); - /* TODO: We can introduce as->affects_decl_identity - and as->affects_decl_reference_identity if attribute mismatch - gets a common reason to give up on merging. It may not be worth - the effort. - For example returns_nonnull affects only references, while - optimize attribute can be ignored because it is already lowered - into flags representation and compared separately. */ - if (!as) - continue; - - attr = lookup_attribute (as->name, CONST_CAST_TREE (a2)); - if (!attr || !attribute_value_equal (a, attr)) - break; - } - if (!a) - { - for (a = a2; a != NULL_TREE; a = TREE_CHAIN (a)) - { - const struct attribute_spec *as; - - as = lookup_attribute_spec (get_attribute_name (a)); - if (!as) - continue; - - if (!lookup_attribute (as->name, CONST_CAST_TREE (a1))) - break; - /* We don't need to compare trees again, as we did this - already in first loop. */ - } - if (!a) - return true; - } - /* TODO: As in comp_type_attributes we may want to introduce target hook. */ - return false; -} - /* Compare properties of symbols N1 and N2 that does not affect semantics of symbol itself but affects semantics of its references from USED_BY (which may be NULL if it is unknown). If comparsion is false, symbols @@ -429,8 +378,8 @@ sem_item::compare_referenced_symbol_properties (symtab_node *used_by, variables just compare attributes for references - the codegen for constructors is affected only by those attributes that we lower to explicit representation (such as DECL_ALIGN or DECL_SECTION). */ - if (!compare_attributes (DECL_ATTRIBUTES (n1->decl), - DECL_ATTRIBUTES (n2->decl))) + if (!attribute_list_equal (DECL_ATTRIBUTES (n1->decl), + DECL_ATTRIBUTES (n2->decl))) return return_false_with_msg ("different var decl attributes"); if (comp_type_attributes (TREE_TYPE (n1->decl), TREE_TYPE (n2->decl)) != 1) @@ -716,8 +665,8 @@ sem_function::equals_wpa (sem_item *item, if (comp_type_attributes (TREE_TYPE (decl), TREE_TYPE (item->decl)) != 1) return return_false_with_msg ("different type attributes"); - if (!compare_attributes (DECL_ATTRIBUTES (decl), - DECL_ATTRIBUTES (item->decl))) + if (!attribute_list_equal (DECL_ATTRIBUTES (decl), + DECL_ATTRIBUTES (item->decl))) return return_false_with_msg ("different decl attributes"); /* The type of THIS pointer type memory location for diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h index a64b3852efb..0359653d2f8 100644 --- a/gcc/ipa-icf.h +++ b/gcc/ipa-icf.h @@ -255,9 +255,6 @@ protected: symtab_node *n2, bool address); - /* Compare two attribute lists. */ - static bool compare_attributes (const_tree list1, const_tree list2); - /* Hash properties compared by compare_referenced_symbol_properties. */ void hash_referenced_symbol_properties (symtab_node *ref, inchash::hash &hstate,