diff options
author | Martin Jambor <mjambor@suse.cz> | 2019-11-25 11:13:08 +0100 |
---|---|---|
committer | Martin Jambor <jamborm@gcc.gnu.org> | 2019-11-25 11:13:08 +0100 |
commit | d0b1b67aabc2b88b58a7485f79d16f9a6d4dd11c (patch) | |
tree | 7c3f46c77d2d21811420a8a0cdaf253c8089c76b | |
parent | ed649cda944c2ff0b77f0203bf83f106e930c5e8 (diff) | |
download | gcc-d0b1b67aabc2b88b58a7485f79d16f9a6d4dd11c.zip gcc-d0b1b67aabc2b88b58a7485f79d16f9a6d4dd11c.tar.gz gcc-d0b1b67aabc2b88b58a7485f79d16f9a6d4dd11c.tar.bz2 |
ipa: Prevent materialization of clones with removed bodies (PR 92109)
2019-11-25 Martin Jambor <mjambor@suse.cz>
PR ipa/92109
* cgraph.h (cgraph_node::remove_from_clone_tree): Declare.
* cgraphclones.c (cgraph_node::remove_from_clone_tree): New method.
(cgraph_materialize_clone): Move removel from clone tree to the
the new method and use it instead.
* ipa.c (symbol_table::remove_unreachable_nodes): When removing
bodies of clones, also remove it from the clone tree.
From-SVN: r278670
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cgraph.h | 4 | ||||
-rw-r--r-- | gcc/cgraphclones.c | 35 | ||||
-rw-r--r-- | gcc/ipa.c | 11 |
4 files changed, 44 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a15cc75..5364edc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,15 @@ 2019-11-25 Martin Jambor <mjambor@suse.cz> + PR ipa/92109 + * cgraph.h (cgraph_node::remove_from_clone_tree): Declare. + * cgraphclones.c (cgraph_node::remove_from_clone_tree): New method. + (cgraph_materialize_clone): Move removel from clone tree to the + the new method and use it instead. + * ipa.c (symbol_table::remove_unreachable_nodes): When removing + bodies of clones, also remove it from the clone tree. + +2019-11-25 Martin Jambor <mjambor@suse.cz> + PR ipa/91956 * ipa-sra.c (process_isra_node_results): Put the new node to the same comdat group as the original node. diff --git a/gcc/cgraph.h b/gcc/cgraph.h index a4f1474..0d2442c 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -967,6 +967,10 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node ipa_param_adjustments *param_adjustments, const char * suffix, unsigned num_suffix); + /* Remove the node from the tree of virtual and inline clones and make it a + standalone node - not a clone any more. */ + void remove_from_clone_tree (); + /* cgraph node being removed from symbol table; see if its entry can be replaced by other inline clone. */ cgraph_node *find_replacement (void); diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c index bfcebb2..ac5c57a 100644 --- a/gcc/cgraphclones.c +++ b/gcc/cgraphclones.c @@ -1013,6 +1013,22 @@ cgraph_node::create_version_clone_with_body return new_version_node; } +/* Remove the node from the tree of virtual and inline clones and make it a + standalone node - not a clone any more. */ + +void cgraph_node::remove_from_clone_tree () +{ + if (next_sibling_clone) + next_sibling_clone->prev_sibling_clone = prev_sibling_clone; + if (prev_sibling_clone) + prev_sibling_clone->next_sibling_clone = next_sibling_clone; + else + clone_of->clones = next_sibling_clone; + next_sibling_clone = NULL; + prev_sibling_clone = NULL; + clone_of = NULL; +} + /* Given virtual clone, turn it into actual clone. */ static void @@ -1033,22 +1049,15 @@ cgraph_materialize_clone (cgraph_node *node) dump_function_to_file (node->decl, symtab->dump_file, dump_flags); } + cgraph_node *clone_of = node->clone_of; /* Function is no longer clone. */ - if (node->next_sibling_clone) - node->next_sibling_clone->prev_sibling_clone = node->prev_sibling_clone; - if (node->prev_sibling_clone) - node->prev_sibling_clone->next_sibling_clone = node->next_sibling_clone; - else - node->clone_of->clones = node->next_sibling_clone; - node->next_sibling_clone = NULL; - node->prev_sibling_clone = NULL; - if (!node->clone_of->analyzed && !node->clone_of->clones) + node->remove_from_clone_tree (); + if (!clone_of->analyzed && !clone_of->clones) { - node->clone_of->release_body (); - node->clone_of->remove_callees (); - node->clone_of->remove_all_references (); + clone_of->release_body (); + clone_of->remove_callees (); + clone_of->remove_all_references (); } - node->clone_of = NULL; bitmap_obstack_release (NULL); } @@ -520,9 +520,14 @@ symbol_table::remove_unreachable_nodes (FILE *file) reliably. */ if (node->alias || node->thunk.thunk_p) ; - else if (!body_needed_for_clonning.contains (node->decl) - && !node->alias && !node->thunk.thunk_p) - node->release_body (); + else if (!body_needed_for_clonning.contains (node->decl)) + { + /* Make the node a non-clone so that we do not attempt to + materialize it later. */ + if (node->clone_of) + node->remove_from_clone_tree (); + node->release_body (); + } else if (!node->clone_of) gcc_assert (in_lto_p || DECL_RESULT (node->decl)); if (node->definition && !node->alias && !node->thunk.thunk_p) |