From patchwork Tue Feb 19 12:43:10 2019 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: 1044641 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-496629-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="vVZlfC8u"; 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 443gQ83Hjbz9s5c for ; Tue, 19 Feb 2019 23:43:26 +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 :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=cuyUftUGi/iOocN57 nrWwe9kIZdGuHPJY6nN5UVSeQAc7UoDHfloviIc5IB6AqkjuAHqirzgeFnkI+02j z99anegcOzbvGnNrfmbftt1nYM+MuMmRggyJr6OAkW1VSWLlilQXKANS77rMZM6M sbgkKFWvnX2sQzov7foOkD7I7M= 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 :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=SlJ2GsU+sI/oDTVpAuIUOuA Qs9Y=; b=vVZlfC8umFAXhW6uKtjx/dL8I3khOWG1ToeHwWiweKYr7PoaIu8lfme bfJ3g+UZydyDM7E8NwqrgyOp6T1cgGAcMxEkExQj+KoGeivuw9er+6JSoAiHXGMo GEPqROsWgcXU9xFdm4GMBQPD5RR6JGWrcgNSKCqtt8JYKvgzLUXw= Received: (qmail 15390 invoked by alias); 19 Feb 2019 12:43:16 -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 15368 invoked by uid 89); 19 Feb 2019 12:43:16 -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=sk:propaga, bellow, Produce, ipareferencec 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; Tue, 19 Feb 2019 12:43:13 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 40846AFB8; Tue, 19 Feb 2019 12:43:11 +0000 (UTC) Subject: [PATCH, stage1] Construct ipa_reduced_postorder always for overwritable (PR ipa/89009). To: Jan Hubicka Cc: Martin Jambor , gcc-patches@gcc.gnu.org References: <376f68fe-91e9-20dc-894d-eac4e085b7dc@suse.cz> <20190211085231.vyj4z4afev5mv2n5@kam.mff.cuni.cz> <20190211134913.gpyri2hpsws4hmjb@kam.mff.cuni.cz> <20190214101935.ss7xmiidftict626@kam.mff.cuni.cz> From: =?utf-8?q?Martin_Li=C5=A1ka?= Message-ID: Date: Tue, 19 Feb 2019 13:43:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190214101935.ss7xmiidftict626@kam.mff.cuni.cz> X-IsSubscribed: yes On 2/14/19 11:19 AM, Jan Hubicka wrote: >> Hi. >> >> This is patch candidate I created and tested. It's not adding >> filtering based on opt_for_fn which I would defer to the next >> stage1. >> >> Patch can bootstrap on x86_64-linux-gnu and survives regression tests. >> >> Ready to be installed? >> Thanks, >> Martin > >> From d036f75a880bc91f67a5473767b35ba2f8a4ffe3 Mon Sep 17 00:00:00 2001 >> From: marxin >> Date: Mon, 11 Feb 2019 16:47:06 +0100 >> Subject: [PATCH] Reduce SCCs in IPA postorder. >> >> gcc/ChangeLog: >> >> 2019-02-13 Martin Liska >> >> * ipa-cp.c (build_toporder_info): Use >> ignore_edge_if_not_available as edge filter. >> * ipa-inline.c (inline_small_functions): Likewise. >> * ipa-pure-const.c (ignore_edge_for_pure_const): >> Move to ipa-utils.h and rename to ignore_edge_if_not_available. >> (propagate_pure_const): Use ignore_edge_if_not_available >> as edge filter. >> * ipa-reference.c (ignore_edge_p): Make SCCs more fine >> based on availability and ECF_LEAF attribute. >> * ipa-utils.c (searchc): Refactor code. >> * ipa-utils.h (ignore_edge_if_not_available): New. > > OK, I think it is safe to wait for stage1 - it is bit fragile to > propagate across different graph then postorder is computed (as > manifested by the bug) but it should be safe if SCCs are simply bigger > then they should be. > > Next stage1 we should also teach the callback to ignore edges of calls > that are not being optimized. I'm sending patch for that. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed after we enter stage1? Thanks, Martin > > Honza >> --- >> gcc/ipa-cp.c | 3 ++- >> gcc/ipa-inline.c | 2 +- >> gcc/ipa-pure-const.c | 13 +------------ >> gcc/ipa-reference.c | 13 ++++++++++--- >> gcc/ipa-utils.c | 3 +-- >> gcc/ipa-utils.h | 10 ++++++++++ >> 6 files changed, 25 insertions(+), 19 deletions(-) >> >> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c >> index 442d5c63eff..2253b0cef63 100644 >> --- a/gcc/ipa-cp.c >> +++ b/gcc/ipa-cp.c >> @@ -815,7 +815,8 @@ build_toporder_info (struct ipa_topo_info *topo) >> topo->stack = XCNEWVEC (struct cgraph_node *, symtab->cgraph_count); >> >> gcc_checking_assert (topo->stack_top == 0); >> - topo->nnodes = ipa_reduced_postorder (topo->order, true, NULL); >> + topo->nnodes = ipa_reduced_postorder (topo->order, true, >> + ignore_edge_if_not_available); >> } >> >> /* Free information about strongly connected components and the arrays in >> diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c >> index 360c3de3289..c7e68a73706 100644 >> --- a/gcc/ipa-inline.c >> +++ b/gcc/ipa-inline.c >> @@ -1778,7 +1778,7 @@ inline_small_functions (void) >> metrics. */ >> >> max_count = profile_count::uninitialized (); >> - ipa_reduced_postorder (order, true, NULL); >> + ipa_reduced_postorder (order, true, ignore_edge_if_not_available); >> free (order); >> >> FOR_EACH_DEFINED_FUNCTION (node) >> diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c >> index a8a3956d2d5..e61d279289e 100644 >> --- a/gcc/ipa-pure-const.c >> +++ b/gcc/ipa-pure-const.c >> @@ -1395,17 +1395,6 @@ cdtor_p (cgraph_node *n, void *) >> return false; >> } >> >> -/* We only propagate across edges with non-interposable callee. */ >> - >> -static bool >> -ignore_edge_for_pure_const (struct cgraph_edge *e) >> -{ >> - enum availability avail; >> - e->callee->function_or_virtual_thunk_symbol (&avail, e->caller); >> - return (avail <= AVAIL_INTERPOSABLE); >> -} >> - >> - >> /* Produce transitive closure over the callgraph and compute pure/const >> attributes. */ >> >> @@ -1423,7 +1412,7 @@ propagate_pure_const (void) >> bool has_cdtor; >> >> order_pos = ipa_reduced_postorder (order, true, >> - ignore_edge_for_pure_const); >> + ignore_edge_if_not_available); >> if (dump_file) >> { >> cgraph_node::dump_cgraph (dump_file); >> diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c >> index d1759a374bc..16cc4cf44f9 100644 >> --- a/gcc/ipa-reference.c >> +++ b/gcc/ipa-reference.c >> @@ -677,14 +677,21 @@ get_read_write_all_from_node (struct cgraph_node *node, >> } >> } >> >> -/* Skip edges from and to nodes without ipa_reference enables. This leave >> - them out of strongy connected coponents and makes them easyto skip in the >> +/* Skip edges from and to nodes without ipa_reference enabled. >> + Ignore not available symbols. This leave >> + them out of strongly connected components and makes them easy to skip in the >> propagation loop bellow. */ >> >> static bool >> ignore_edge_p (cgraph_edge *e) >> { >> - return (!opt_for_fn (e->caller->decl, flag_ipa_reference) >> + enum availability avail; >> + e->callee->function_or_virtual_thunk_symbol (&avail, e->caller); >> + >> + return (avail < AVAIL_INTERPOSABLE >> + || (avail == AVAIL_INTERPOSABLE >> + && !(flags_from_decl_or_type (e->callee->decl) & ECF_LEAF)) >> + || !opt_for_fn (e->caller->decl, flag_ipa_reference) >> || !opt_for_fn (e->callee->function_symbol ()->decl, >> flag_ipa_reference)); >> } >> diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c >> index 79b250c3943..25c2e2cf789 100644 >> --- a/gcc/ipa-utils.c >> +++ b/gcc/ipa-utils.c >> @@ -103,8 +103,7 @@ searchc (struct searchc_env* env, struct cgraph_node *v, >> continue; >> >> if (w->aux >> - && (avail > AVAIL_INTERPOSABLE >> - || avail == AVAIL_INTERPOSABLE)) >> + && (avail >= AVAIL_INTERPOSABLE)) >> { >> w_info = (struct ipa_dfs_info *) w->aux; >> if (w_info->new_node) >> diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h >> index b70e8c57108..aad08148348 100644 >> --- a/gcc/ipa-utils.h >> +++ b/gcc/ipa-utils.h >> @@ -262,6 +262,16 @@ odr_type_p (const_tree t) >> return false; >> } >> >> +/* We only propagate across edges with non-interposable callee. */ >> + >> +inline bool >> +ignore_edge_if_not_available (struct cgraph_edge *e) >> +{ >> + enum availability avail; >> + e->callee->function_or_virtual_thunk_symbol (&avail, e->caller); >> + return (avail <= AVAIL_INTERPOSABLE); >> +} >> + >> #endif /* GCC_IPA_UTILS_H */ >> >> >> -- >> 2.20.1 >> > From cd7ad04cd1e0ec0d10dc858c22f7e486a3fab183 Mon Sep 17 00:00:00 2001 From: marxin Date: Mon, 11 Feb 2019 16:47:06 +0100 Subject: [PATCH] Reduce SCCs in IPA postorder. gcc/ChangeLog: 2019-02-19 Martin Liska * ipa-cp.c (ignore_edge_p): New function. (build_toporder_info): Use it. * ipa-inline.c (ignore_edge_p): New function/ (inline_small_functions): Use it. * ipa-pure-const.c (ignore_edge_for_nothrow): Verify opt_for_fn for caller and callee. (ignore_edge_for_pure_const): Likewise. * ipa-reference.c (ignore_edge_p): Extend to check for opt_for_fn. * ipa-utils.c (searchc): Refactor. * ipa-utils.h: Fix coding style. --- gcc/ipa-cp.c | 18 +++++++++++++++++- gcc/ipa-inline.c | 12 +++++++++++- gcc/ipa-pure-const.c | 17 ++++++++++++----- gcc/ipa-reference.c | 13 ++++++++++--- gcc/ipa-utils.c | 3 +-- gcc/ipa-utils.h | 2 -- 6 files changed, 51 insertions(+), 14 deletions(-) diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 442d5c63eff..004b3a34b1c 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -806,6 +806,21 @@ public: {} }; +/* Skip edges from and to nodes without ipa_cp enabled. + Ignore not available symbols. */ + +static bool +ignore_edge_p (cgraph_edge *e) +{ + enum availability avail; + e->callee->function_or_virtual_thunk_symbol (&avail, e->caller); + + return (avail <= AVAIL_INTERPOSABLE + || !opt_for_fn (e->caller->decl, flag_ipa_cp) + || !opt_for_fn (e->callee->function_symbol ()->decl, + flag_ipa_cp)); +} + /* Allocate the arrays in TOPO and topologically sort the nodes into order. */ static void @@ -815,7 +830,8 @@ build_toporder_info (struct ipa_topo_info *topo) topo->stack = XCNEWVEC (struct cgraph_node *, symtab->cgraph_count); gcc_checking_assert (topo->stack_top == 0); - topo->nnodes = ipa_reduced_postorder (topo->order, true, NULL); + topo->nnodes = ipa_reduced_postorder (topo->order, true, + ignore_edge_p); } /* Free information about strongly connected components and the arrays in diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 360c3de3289..d6314bc0e57 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -1751,6 +1751,16 @@ sum_callers (struct cgraph_node *node, void *data) return false; } +/* We only propagate across edges with non-interposable callee. */ + +inline bool +ignore_edge_p (struct cgraph_edge *e) +{ + enum availability avail; + e->callee->function_or_virtual_thunk_symbol (&avail, e->caller); + return (avail <= AVAIL_INTERPOSABLE); +} + /* We use greedy algorithm for inlining of small functions: All inline candidates are put into prioritized heap ordered in increasing badness. @@ -1778,7 +1788,7 @@ inline_small_functions (void) metrics. */ max_count = profile_count::uninitialized (); - ipa_reduced_postorder (order, true, NULL); + ipa_reduced_postorder (order, true, ignore_edge_p); free (order); FOR_EACH_DEFINED_FUNCTION (node) diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index bb561d00853..ce69457cbbf 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -1365,8 +1365,11 @@ ignore_edge_for_nothrow (struct cgraph_edge *e) e->caller); if (avail <= AVAIL_INTERPOSABLE || TREE_NOTHROW (n->decl)) return true; - return opt_for_fn (e->callee->decl, flag_non_call_exceptions) - && !e->callee->binds_to_current_def_p (e->caller); + return ((opt_for_fn (e->callee->decl, flag_non_call_exceptions) + && !e->callee->binds_to_current_def_p (e->caller)) + || !opt_for_fn (e->caller->decl, flag_ipa_pure_const) + || !opt_for_fn (e->callee->function_symbol ()->decl, + flag_ipa_pure_const)); } /* Return true if NODE is self recursive function. @@ -1396,16 +1399,20 @@ cdtor_p (cgraph_node *n, void *) return false; } -/* We only propagate across edges with non-interposable callee. */ +/* Skip edges from and to nodes without ipa_pure_const enabled. + Ignore not available symbols. */ static bool ignore_edge_for_pure_const (struct cgraph_edge *e) { enum availability avail; e->callee->function_or_virtual_thunk_symbol (&avail, e->caller); - return (avail <= AVAIL_INTERPOSABLE); -} + return (avail <= AVAIL_INTERPOSABLE + || !opt_for_fn (e->caller->decl, flag_ipa_pure_const) + || !opt_for_fn (e->callee->function_symbol ()->decl, + flag_ipa_pure_const)); +} /* Produce transitive closure over the callgraph and compute pure/const attributes. */ diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c index 9ef03c2505b..8074d767781 100644 --- a/gcc/ipa-reference.c +++ b/gcc/ipa-reference.c @@ -676,14 +676,21 @@ get_read_write_all_from_node (struct cgraph_node *node, } } -/* Skip edges from and to nodes without ipa_reference enables. This leave - them out of strongy connected coponents and makes them easyto skip in the +/* Skip edges from and to nodes without ipa_reference enabled. + Ignore not available symbols. This leave + them out of strongly connected components and makes them easy to skip in the propagation loop bellow. */ static bool ignore_edge_p (cgraph_edge *e) { - return (!opt_for_fn (e->caller->decl, flag_ipa_reference) + enum availability avail; + e->callee->function_or_virtual_thunk_symbol (&avail, e->caller); + + return (avail < AVAIL_INTERPOSABLE + || (avail == AVAIL_INTERPOSABLE + && !(flags_from_decl_or_type (e->callee->decl) & ECF_LEAF)) + || !opt_for_fn (e->caller->decl, flag_ipa_reference) || !opt_for_fn (e->callee->function_symbol ()->decl, flag_ipa_reference)); } diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c index 79b250c3943..25c2e2cf789 100644 --- a/gcc/ipa-utils.c +++ b/gcc/ipa-utils.c @@ -103,8 +103,7 @@ searchc (struct searchc_env* env, struct cgraph_node *v, continue; if (w->aux - && (avail > AVAIL_INTERPOSABLE - || avail == AVAIL_INTERPOSABLE)) + && (avail >= AVAIL_INTERPOSABLE)) { w_info = (struct ipa_dfs_info *) w->aux; if (w_info->new_node) diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h index b70e8c57108..c4a9664852a 100644 --- a/gcc/ipa-utils.h +++ b/gcc/ipa-utils.h @@ -263,5 +263,3 @@ odr_type_p (const_tree t) } #endif /* GCC_IPA_UTILS_H */ - - -- 2.20.1