From: "Martin Liška" <mliska@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: GCC 9 backports
Date: Fri, 23 Aug 2019 11:56:00 -0000 [thread overview]
Message-ID: <f62e0853-a604-891d-8e7d-14e8cdc2423e@suse.cz> (raw)
In-Reply-To: <eac18596-f6bf-9657-4d0e-f9c567ed7089@suse.cz>
[-- Attachment #1: Type: text/plain, Size: 66 bytes --]
There are 3 more tested patches that I going to backport.
Martin
[-- Attachment #2: 0003-Backport-r274504.patch --]
[-- Type: text/x-patch, Size: 1600 bytes --]
From a413f183a85bc9a08e3dcd9e9d617086fce86460 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 15 Aug 2019 06:58:36 +0000
Subject: [PATCH 3/3] Backport r274504
gcc/ChangeLog:
2019-08-15 Martin Liska <mliska@suse.cz>
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
[-- Attachment #3: 0002-Backport-r274503.patch --]
[-- Type: text/x-patch, Size: 1234 bytes --]
From 7fad5cd74a282bc49b14c4d9a5a95b3d1a212394 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 15 Aug 2019 06:58:26 +0000
Subject: [PATCH 2/3] Backport r274503
gcc/ChangeLog:
2019-08-15 Martin Liska <mliska@suse.cz>
* 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
[-- Attachment #4: 0001-Backport-r274502.patch --]
[-- Type: text/x-patch, Size: 4829 bytes --]
From ebcb363be811c20d678dc7b985e68ca86afe4707 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 15 Aug 2019 06:58:09 +0000
Subject: [PATCH 1/3] Backport r274502
gcc/ChangeLog:
2019-08-15 Martin Liska <mliska@suse.cz>
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<int_hash <int, 0, -1> >
-
/* 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<cgraph_node *> *removed_nodes = (hash_set<cgraph_node *> *)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<cgraph_node *> *removed_nodes = (hash_set<cgraph_node *> *)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<cgraph_node *> *removed_nodes = (hash_set<cgraph_node *> *)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<cgraph_node *> (symtab->cgraph_count);
+ hash_set<cgraph_node *> 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
next prev parent reply other threads:[~2019-08-23 11:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-14 8:45 Martin Liška
2019-05-14 8:47 ` Martin Liška
2019-05-24 7:43 ` Martin Liška
2019-07-04 9:23 ` Martin Liška
2019-07-22 9:36 ` Martin Liška
2019-08-23 11:56 ` Martin Liška [this message]
2019-09-02 8:56 ` Martin Liška
2019-10-23 12:12 ` Martin Liška
2020-02-28 17:51 ` Martin Liška
2020-03-10 10:09 ` Martin Liška
2020-04-03 10:32 ` Martin Liška
2020-04-20 9:25 ` Martin Liška
2020-10-02 10:05 ` Martin Liška
2020-10-02 11:15 ` Martin Liška
2020-10-15 9:07 ` Martin Liška
2020-10-16 8:51 ` Martin Liška
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f62e0853-a604-891d-8e7d-14e8cdc2423e@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).