From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71574 invoked by alias); 1 Mar 2015 00:26:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 71561 invoked by uid 89); 1 Mar 2015 00:26:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 01 Mar 2015 00:26:39 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id C14715440B6; Sun, 1 Mar 2015 01:26:35 +0100 (CET) Date: Sun, 01 Mar 2015 00:26:00 -0000 From: Jan Hubicka To: Martin =?iso-8859-2?Q?Li=B9ka?= Cc: "gcc-pat >> GCC Patches" , "hubicka >> Jan Hubicka" Subject: Re: [PATCH] ICF: move readonly decision for variables to the right place Message-ID: <20150301002635.GG20437@kam.mff.cuni.cz> References: <54F25A19.10903@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54F25A19.10903@suse.cz> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-03/txt/msg00002.txt.bz2 > diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c > index 864a5d0..5b1fcff 100644 > --- a/gcc/ipa-icf.c > +++ b/gcc/ipa-icf.c > @@ -1410,10 +1410,6 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack) > if (node->alias) > return NULL; > > - bool readonly = TYPE_P (decl) ? TYPE_READONLY (decl) : TREE_READONLY (decl); > - if (!readonly) > - return NULL; > - > bool can_handle = DECL_VIRTUAL_P (decl) > || flag_merge_constants >= 2 > || (!TREE_ADDRESSABLE (decl) && !node->externally_visible); Please also drop can_handle and DECL_EXTERNAL check here. can_handle seems to test if address matters. We already verify it at merging time and at a time we consider REF_ADDR references. This is enough. Moreover TREE_ADDRESSABLE and externally_visible flags are subject to change in between analysis and WPA time. Instead of this punt if THIS_VOLATILE is true. Instead of ctor_for_folding bellow use DECL_INITIAL (ctor_for_folding may return you NULL if it thinks the var is not safe) > @@ -1900,7 +1896,14 @@ sem_item_optimizer::filter_removed_items (void) > if (!flag_ipa_icf_variables) > remove_item (item); > else > - filtered.safe_push (item); > + { > + /* Filter out non-readonly variables. */ > + tree decl = item->decl; > + if (TYPE_P (decl) ? TYPE_READONLY (decl) : TREE_READONLY (decl)) Just test TREE_READONLY (decl). OK with these changes. Honza