diff options
author | Martin Jambor <mjambor@suse.cz> | 2014-12-05 12:06:26 +0100 |
---|---|---|
committer | Martin Jambor <jamborm@gcc.gnu.org> | 2014-12-05 12:06:26 +0100 |
commit | 6a4bad955f8ab028190bbb4d3cf3c00721c26bfc (patch) | |
tree | 5535b89bdfdb34a70839578dacb6e9d89a13a6df /gcc/cgraphclones.c | |
parent | 612b47110ab93289e9d7fb4751e9f46fbd7d3485 (diff) | |
download | gcc-6a4bad955f8ab028190bbb4d3cf3c00721c26bfc.zip gcc-6a4bad955f8ab028190bbb4d3cf3c00721c26bfc.tar.gz gcc-6a4bad955f8ab028190bbb4d3cf3c00721c26bfc.tar.bz2 |
cgraph.h (cgraph_node): New method expand_all_artificial_thunks.
2014-12-05 Martin Jambor <mjambor@suse.cz>
* cgraph.h (cgraph_node): New method expand_all_artificial_thunks.
(cgraph_edge): New method redirect_callee_duplicating_thunks.
* cgraphclones.c (duplicate_thunk_for_node): Donot expand newly
created thunks.
(redirect_edge_duplicating_thunks): Turned into edge method
redirect_callee_duplicating_thunks.
(cgraph_node::expand_all_artificial_thunks): New method.
(create_clone): Call expand_all_artificial_thunks.
* ipa-cp.c (perhaps_add_new_callers): Call
redirect_callee_duplicating_thunks instead of redirect_callee.
Also call expand_all_artificial_thunks.
From-SVN: r218417
Diffstat (limited to 'gcc/cgraphclones.c')
-rw-r--r-- | gcc/cgraphclones.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c index 086dd92..1bf0477 100644 --- a/gcc/cgraphclones.c +++ b/gcc/cgraphclones.c @@ -370,28 +370,47 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node) CGRAPH_FREQ_BASE); e->call_stmt_cannot_inline_p = true; symtab->call_edge_duplication_hooks (thunk->callees, e); - if (new_thunk->expand_thunk (false, false)) - { - new_thunk->thunk.thunk_p = false; - new_thunk->analyze (); - } - symtab->call_cgraph_duplication_hooks (thunk, new_thunk); return new_thunk; } /* If E does not lead to a thunk, simply redirect it to N. Otherwise create one or more equivalent thunks for N and redirect E to the first in the - chain. */ + chain. Note that it is then necessary to call + n->expand_all_artificial_thunks once all callers are redirected. */ void -redirect_edge_duplicating_thunks (cgraph_edge *e, cgraph_node *n) +cgraph_edge::redirect_callee_duplicating_thunks (cgraph_node *n) { - cgraph_node *orig_to = e->callee->ultimate_alias_target (); + cgraph_node *orig_to = callee->ultimate_alias_target (); if (orig_to->thunk.thunk_p) n = duplicate_thunk_for_node (orig_to, n); - e->redirect_callee (n); + redirect_callee (n); +} + +/* Call expand_thunk on all callers that are thunks and if analyze those nodes + that were expanded. */ + +void +cgraph_node::expand_all_artificial_thunks () +{ + cgraph_edge *e; + for (e = callers; e;) + if (e->caller->thunk.thunk_p) + { + cgraph_node *thunk = e->caller; + + e = e->next_caller; + if (thunk->expand_thunk (false, false)) + { + thunk->thunk.thunk_p = false; + thunk->analyze (); + } + thunk->expand_all_artificial_thunks (); + } + else + e = e->next_caller; } /* Create node representing clone of N executed COUNT times. Decrease @@ -483,8 +502,9 @@ cgraph_node::create_clone (tree decl, gcov_type gcov_count, int freq, if (!e->callee || DECL_BUILT_IN_CLASS (e->callee->decl) != BUILT_IN_NORMAL || DECL_FUNCTION_CODE (e->callee->decl) != BUILT_IN_UNREACHABLE) - redirect_edge_duplicating_thunks (e, new_node); + e->redirect_callee_duplicating_thunks (new_node); } + new_node->expand_all_artificial_thunks (); for (e = callees;e; e=e->next_callee) e->clone (new_node, e->call_stmt, e->lto_stmt_uid, count_scale, |