From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 82709 invoked by alias); 23 Aug 2019 11:40:32 -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 82643 invoked by uid 89); 23 Aug 2019 11:40:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_SOFTFAIL autolearn=ham version=3.3.1 spammy=aux, collected X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Aug 2019 11:40:29 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i17vd-0007Xd-PM for gcc-patches@gcc.gnu.org; Fri, 23 Aug 2019 07:40:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:46878 helo=mx1.suse.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i17vd-0007Tk-4o for gcc-patches@gcc.gnu.org; Fri, 23 Aug 2019 07:40:25 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 85C3EB06B for ; Fri, 23 Aug 2019 11:40:13 +0000 (UTC) Subject: Re: GCC 9 backports From: =?UTF-8?Q?Martin_Li=c5=a1ka?= To: GCC Patches References: <97ec7d16-eebe-4124-7018-22242c76a797@suse.cz> <39bf5f1b-373f-6a27-c4ba-0ce3791bd395@suse.cz> Message-ID: Date: Fri, 23 Aug 2019 11:56:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------FC523B5E56FD1D908FC7F78E" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg01640.txt.bz2 This is a multi-part message in MIME format. --------------FC523B5E56FD1D908FC7F78E Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 66 There are 3 more tested patches that I going to backport. Martin --------------FC523B5E56FD1D908FC7F78E Content-Type: text/x-patch; name="0003-Backport-r274504.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0003-Backport-r274504.patch" Content-length: 1601 >From a413f183a85bc9a08e3dcd9e9d617086fce86460 Mon Sep 17 00:00:00 2001 From: marxin Date: Thu, 15 Aug 2019 06:58:36 +0000 Subject: [PATCH 3/3] Backport r274504 gcc/ChangeLog: 2019-08-15 Martin Liska PR ipa/91438 * cgraph.c (cgraph_node::remove): When setting n->origin = NULL for all nested functions, reset also next_nested. --- gcc/cgraph.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gcc/cgraph.c b/gcc/cgraph.c index d9e7353bd7b..1febb6369a0 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1779,8 +1779,6 @@ cgraph_node::release_body (bool keep_arguments) void cgraph_node::remove (void) { - cgraph_node *n; - if (symtab->ipa_clones_dump_file && symtab->cloned_nodes.contains (this)) fprintf (symtab->ipa_clones_dump_file, "Callgraph removal;%s;%d;%s;%d;%d\n", asm_name (), order, @@ -1797,8 +1795,13 @@ cgraph_node::remove (void) */ force_output = false; forced_by_abi = false; - for (n = nested; n; n = n->next_nested) + cgraph_node *next = nested; + for (cgraph_node *n = nested; n; n = next) + { + next = n->next_nested; n->origin = NULL; + n->next_nested = NULL; + } nested = NULL; if (origin) { @@ -1852,7 +1855,7 @@ cgraph_node::remove (void) */ if (symtab->state != LTO_STREAMING) { - n = cgraph_node::get (decl); + cgraph_node *n = cgraph_node::get (decl); if (!n || (!n->clones && !n->clone_of && !n->global.inlined_to && ((symtab->global_info_ready || in_lto_p) -- 2.22.1 --------------FC523B5E56FD1D908FC7F78E Content-Type: text/x-patch; name="0002-Backport-r274503.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-Backport-r274503.patch" Content-length: 1235 >From 7fad5cd74a282bc49b14c4d9a5a95b3d1a212394 Mon Sep 17 00:00:00 2001 From: marxin Date: Thu, 15 Aug 2019 06:58:26 +0000 Subject: [PATCH 2/3] Backport r274503 gcc/ChangeLog: 2019-08-15 Martin Liska * cgraph.c (cgraph_node::verify_node): Verify origin, nested and next_nested. --- gcc/cgraph.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gcc/cgraph.c b/gcc/cgraph.c index db4c9c747b9..d9e7353bd7b 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -3449,6 +3449,30 @@ cgraph_node::verify_node (void) e->aux = 0; } } + + if (nested != NULL) + { + for (cgraph_node *n = nested; n != NULL; n = n->next_nested) + { + if (n->origin == NULL) + { + error ("missing origin for a node in a nested list"); + error_found = true; + } + else if (n->origin != this) + { + error ("origin points to a different parent"); + error_found = true; + break; + } + } + } + if (next_nested != NULL && origin == NULL) + { + error ("missing origin for a node in a nested list"); + error_found = true; + } + if (error_found) { dump (stderr); -- 2.22.1 --------------FC523B5E56FD1D908FC7F78E Content-Type: text/x-patch; name="0001-Backport-r274502.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Backport-r274502.patch" Content-length: 4830 >From ebcb363be811c20d678dc7b985e68ca86afe4707 Mon Sep 17 00:00:00 2001 From: marxin Date: Thu, 15 Aug 2019 06:58:09 +0000 Subject: [PATCH 1/3] Backport r274502 gcc/ChangeLog: 2019-08-15 Martin Liska PR ipa/91404 * passes.c (order): Remove. (uid_hash_t): Likewise). (remove_cgraph_node_from_order): Remove from set of pointers (cgraph_node *). (insert_cgraph_node_to_order): New. (duplicate_cgraph_node_to_order): New. (do_per_function_toporder): Register all 3 cgraph hooks. Skip removed_nodes now as we know about all of them. --- gcc/passes.c | 68 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/gcc/passes.c b/gcc/passes.c index d8d479a1c17..092dafbd488 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -1646,24 +1646,39 @@ do_per_function (void (*callback) (function *, void *data), void *data) } } -/* Because inlining might remove no-longer reachable nodes, we need to - keep the array visible to garbage collector to avoid reading collected - out nodes. */ -static int nnodes; -static GTY ((length ("nnodes"))) cgraph_node **order; - -#define uid_hash_t hash_set > - /* Hook called when NODE is removed and therefore should be excluded from order vector. DATA is a hash set with removed nodes. */ static void remove_cgraph_node_from_order (cgraph_node *node, void *data) { - uid_hash_t *removed_nodes = (uid_hash_t *)data; - removed_nodes->add (node->get_uid ()); + hash_set *removed_nodes = (hash_set *)data; + removed_nodes->add (node); +} + +/* Hook called when NODE is insert and therefore should be + excluded from removed_nodes. DATA is a hash set with removed nodes. */ + +static void +insert_cgraph_node_to_order (cgraph_node *node, void *data) +{ + hash_set *removed_nodes = (hash_set *)data; + removed_nodes->remove (node); } +/* Hook called when NODE is duplicated and therefore should be + excluded from removed_nodes. DATA is a hash set with removed nodes. */ + +static void +duplicate_cgraph_node_to_order (cgraph_node *node, cgraph_node *node2, + void *data) +{ + hash_set *removed_nodes = (hash_set *)data; + gcc_checking_assert (!removed_nodes->contains (node)); + removed_nodes->remove (node2); +} + + /* If we are in IPA mode (i.e., current_function_decl is NULL), call function CALLBACK for every function in the call graph. Otherwise, call CALLBACK on the current function. @@ -1677,26 +1692,30 @@ do_per_function_toporder (void (*callback) (function *, void *data), void *data) callback (cfun, data); else { - cgraph_node_hook_list *hook; - uid_hash_t removed_nodes; - gcc_assert (!order); - order = ggc_vec_alloc (symtab->cgraph_count); + hash_set removed_nodes; + unsigned nnodes = symtab->cgraph_count; + cgraph_node **order = XNEWVEC (cgraph_node *, nnodes); nnodes = ipa_reverse_postorder (order); for (i = nnodes - 1; i >= 0; i--) order[i]->process = 1; - hook = symtab->add_cgraph_removal_hook (remove_cgraph_node_from_order, - &removed_nodes); + cgraph_node_hook_list *removal_hook + = symtab->add_cgraph_removal_hook (remove_cgraph_node_from_order, + &removed_nodes); + cgraph_node_hook_list *insertion_hook + = symtab->add_cgraph_insertion_hook (insert_cgraph_node_to_order, + &removed_nodes); + cgraph_2node_hook_list *duplication_hook + = symtab->add_cgraph_duplication_hook (duplicate_cgraph_node_to_order, + &removed_nodes); for (i = nnodes - 1; i >= 0; i--) { cgraph_node *node = order[i]; /* Function could be inlined and removed as unreachable. */ - if (node == NULL || removed_nodes.contains (node->get_uid ())) + if (node == NULL || removed_nodes.contains (node)) continue; - /* Allow possibly removed nodes to be garbage collected. */ - order[i] = NULL; node->process = 0; if (node->has_gimple_body_p ()) { @@ -1706,11 +1725,12 @@ do_per_function_toporder (void (*callback) (function *, void *data), void *data) pop_cfun (); } } - symtab->remove_cgraph_removal_hook (hook); + symtab->remove_cgraph_removal_hook (removal_hook); + symtab->remove_cgraph_insertion_hook (insertion_hook); + symtab->remove_cgraph_duplication_hook (duplication_hook); + + free (order); } - ggc_free (order); - order = NULL; - nnodes = 0; } /* Helper function to perform function body dump. */ @@ -3060,5 +3080,3 @@ function_called_by_processed_nodes_p (void) } return e != NULL; } - -#include "gt-passes.h" -- 2.22.1 --------------FC523B5E56FD1D908FC7F78E--