From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108165 invoked by alias); 19 Jan 2017 15:02:35 -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 107481 invoked by uid 89); 19 Jan 2017 15:02:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=1319, VAL X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Jan 2017 15:02:24 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 06AF9ACF5; Thu, 19 Jan 2017 15:02:21 +0000 (UTC) Subject: Re: [PATCH] Fix IPA CP where it forgot to add a reference in cgraph To: Jan Hubicka References: <6421e992-7681-1456-2a73-ba79fd8b00c1@suse.cz> <20161220100634.xmespxfr2nurhilo@virgil.suse.cz> <87b66126-34a7-4935-d078-a14d979b3c9a@suse.cz> <20170118221825.GC91755@kam.mff.cuni.cz> Cc: GCC Patches From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <39688a01-a88d-8bcc-1a6b-f57d87538649@suse.cz> Date: Thu, 19 Jan 2017 15:09:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170118221825.GC91755@kam.mff.cuni.cz> Content-Type: multipart/mixed; boundary="------------2AD664B705F97BCC18E175A1" X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg01473.txt.bz2 This is a multi-part message in MIME format. --------------2AD664B705F97BCC18E175A1 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Content-length: 2883 On 01/18/2017 11:18 PM, Jan Hubicka wrote: >> >> 2016-12-19 Martin Liska >> >> * cgraphclones.c (cgraph_node::create_virtual_clone): >> Create either IPA_REF_LOAD of IPA_REF_READ depending on >> whether new_tree is a VAR_DECL or an ADDR_EXPR. >> * ipa-cp.c (create_specialized_node): Add reference just for >> ADDR_EXPRs. >> * symtab.c (symtab_node::maybe_create_reference): Remove guard >> as it's guarded in callers. >> --- >> gcc/cgraphclones.c | 6 +++++- >> gcc/ipa-cp.c | 3 ++- >> gcc/symtab.c | 2 -- >> 3 files changed, 7 insertions(+), 4 deletions(-) >> >> diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c >> index 349892dab67..6c8fe156f23 100644 >> --- a/gcc/cgraphclones.c >> +++ b/gcc/cgraphclones.c >> @@ -624,7 +624,11 @@ cgraph_node::create_virtual_clone (vec redirect_callers, >> || in_lto_p) >> new_node->unique_name = true; >> FOR_EACH_VEC_SAFE_ELT (tree_map, i, map) >> - new_node->maybe_create_reference (map->new_tree, IPA_REF_ADDR, NULL); >> + { >> + ipa_ref_use use_type >> + = TREE_CODE (map->new_tree) == ADDR_EXPR ? IPA_REF_ADDR : IPA_REF_LOAD; >> + new_node->maybe_create_reference (map->new_tree, use_type, NULL); >> + } >> >> if (ipa_transforms_to_apply.exists ()) >> new_node->ipa_transforms_to_apply >> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c >> index d3b50524457..fd312b56fde 100644 >> --- a/gcc/ipa-cp.c >> +++ b/gcc/ipa-cp.c >> @@ -3787,7 +3787,8 @@ create_specialized_node (struct cgraph_node *node, >> args_to_skip, "constprop"); >> ipa_set_node_agg_value_chain (new_node, aggvals); >> for (av = aggvals; av; av = av->next) >> - new_node->maybe_create_reference (av->value, IPA_REF_ADDR, NULL); >> + if (TREE_CODE (av->value) == ADDR_EXPR) >> + new_node->maybe_create_reference (av->value, IPA_REF_ADDR, NULL); >> >> if (dump_file && (dump_flags & TDF_DETAILS)) >> { >> diff --git a/gcc/symtab.c b/gcc/symtab.c >> index 73168a8db09..562a4a2f6a6 100644 >> --- a/gcc/symtab.c >> +++ b/gcc/symtab.c >> @@ -598,8 +598,6 @@ symtab_node::maybe_create_reference (tree val, enum ipa_ref_use use_type, >> gimple *stmt) >> { >> STRIP_NOPS (val); >> - if (TREE_CODE (val) != ADDR_EXPR) >> - return NULL; > > Perhaps maybe_create_reference should drop the use_type argument (it is used > with IPA_REF_ADDR only anyway) and should do the parsing itself? > I.e. if there is reference do IPA_REF_LOAD and if there is ADDR_EXPR do > IPA_REF_ADDR. Why one can not have handled component refs in there? > > Honza Ok, this is updated version that I've been testing. Added a reference to PR that we just identified that is also caused by IPA CP and will be fixed by the patch. Thanks, Martin >> val = get_base_var (val); >> if (val && VAR_OR_FUNCTION_DECL_P (val)) >> { >> -- >> 2.11.0 >> > --------------2AD664B705F97BCC18E175A1 Content-Type: text/x-patch; name="0001-Fix-IPA-CP-where-it-forgot-to-add-a-reference-in-cgr.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Fix-IPA-CP-where-it-forgot-to-add-a-reference-in-cgr.pa"; filename*1="tch" Content-length: 3784 >From f42c5ea2ce09ecbf02e472ce31add53189115d66 Mon Sep 17 00:00:00 2001 From: marxin Date: Mon, 19 Dec 2016 11:03:34 +0100 Subject: [PATCH] Fix IPA CP where it forgot to add a reference in cgraph (PR ipa/71190). gcc/ChangeLog: 2017-01-19 Martin Liska PR ipa/71190 * cgraph.h (maybe_create_reference): Remove argument and update comment. * cgraphclones.c (cgraph_node::create_virtual_clone): Remove one argument. * ipa-cp.c (create_specialized_node): Likewise. * symtab.c (symtab_node::maybe_create_reference): Handle VAR_DECLs and ADDR_EXPRs and select ipa_ref_use type. --- gcc/cgraph.h | 6 ++---- gcc/cgraphclones.c | 2 +- gcc/ipa-cp.c | 2 +- gcc/symtab.c | 24 +++++++++++++++--------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/gcc/cgraph.h b/gcc/cgraph.h index db2915c5751..5410a71176a 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -131,11 +131,9 @@ public: enum ipa_ref_use use_type, gimple *stmt); /* If VAL is a reference to a function or a variable, add a reference from - this symtab_node to the corresponding symbol table node. USE_TYPE specify - type of the use and STMT the statement (if it exists). Return the new + this symtab_node to the corresponding symbol table node. Return the new reference or NULL if none was created. */ - ipa_ref *maybe_create_reference (tree val, enum ipa_ref_use use_type, - gimple *stmt); + ipa_ref *maybe_create_reference (tree val, gimple *stmt); /* Clone all references from symtab NODE to this symtab_node. */ void clone_references (symtab_node *node); diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c index a17663519a9..c2337e84553 100644 --- a/gcc/cgraphclones.c +++ b/gcc/cgraphclones.c @@ -624,7 +624,7 @@ cgraph_node::create_virtual_clone (vec redirect_callers, || in_lto_p) new_node->unique_name = true; FOR_EACH_VEC_SAFE_ELT (tree_map, i, map) - new_node->maybe_create_reference (map->new_tree, IPA_REF_ADDR, NULL); + new_node->maybe_create_reference (map->new_tree, NULL); if (ipa_transforms_to_apply.exists ()) new_node->ipa_transforms_to_apply diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 9cc903769e8..aa3c9973a66 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -3786,7 +3786,7 @@ create_specialized_node (struct cgraph_node *node, args_to_skip, "constprop"); ipa_set_node_agg_value_chain (new_node, aggvals); for (av = aggvals; av; av = av->next) - new_node->maybe_create_reference (av->value, IPA_REF_ADDR, NULL); + new_node->maybe_create_reference (av->value, NULL); if (dump_file && (dump_flags & TDF_DETAILS)) { diff --git a/gcc/symtab.c b/gcc/symtab.c index 87120970d34..64abf32ae13 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -588,18 +588,24 @@ symtab_node::create_reference (symtab_node *referred_node, return ref; } -/* If VAL is a reference to a function or a variable, add a reference from - this symtab_node to the corresponding symbol table node. USE_TYPE specify - type of the use and STMT the statement (if it exists). Return the new - reference or NULL if none was created. */ - ipa_ref * -symtab_node::maybe_create_reference (tree val, enum ipa_ref_use use_type, - gimple *stmt) +symtab_node::maybe_create_reference (tree val, gimple *stmt) { STRIP_NOPS (val); - if (TREE_CODE (val) != ADDR_EXPR) - return NULL; + ipa_ref_use use_type; + + switch (TREE_CODE (val)) + { + case VAR_DECL: + use_type = IPA_REF_LOAD; + break; + case ADDR_EXPR: + use_type = IPA_REF_ADDR; + break; + default: + return NULL; + } + val = get_base_var (val); if (val && VAR_OR_FUNCTION_DECL_P (val)) { -- 2.11.0 --------------2AD664B705F97BCC18E175A1--