diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-08-30 09:46:19 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-08-30 09:46:19 +0000 |
commit | b9825313eeb5bc4ec94af5e600a18acf8d0f9c3b (patch) | |
tree | 2acd1c50be0f353991823e0873d49d8c122e29d7 | |
parent | f93009a49b6af8fbb0890d7d6e81765083595c2a (diff) | |
download | gcc-b9825313eeb5bc4ec94af5e600a18acf8d0f9c3b.tar.gz |
* ipa-inline.c (cgraph_estimate_growth): Discover self recursive
functions.
(cgraph_decide_inlining_of_small_function): Use edge->count to detect
profile presence locally.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139800 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ipa-inline.c | 30 |
2 files changed, 28 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f8fcf7bbf41..b712a12dec9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2008-08-30 Jan Hubicka <jh@suse.cz> + + * ipa-inline.c (cgraph_estimate_growth): Discover self recursive + functions. + (cgraph_decide_inlining_of_small_function): Use edge->count to detect + profile presence locally. + 2008-08-29 Joseph Myers <joseph@codesourcery.com> PR bootstrap/37086 diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index a85a8a3be6b..4c8096ae9b6 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -318,18 +318,25 @@ cgraph_estimate_growth (struct cgraph_node *node) { int growth = 0; struct cgraph_edge *e; + bool self_recursive = false; + if (node->global.estimated_growth != INT_MIN) return node->global.estimated_growth; for (e = node->callers; e; e = e->next_caller) - if (e->inline_failed) - growth += (cgraph_estimate_size_after_inlining (1, e->caller, node) - - e->caller->global.insns); + { + if (e->caller == node) + self_recursive = true; + if (e->inline_failed) + growth += (cgraph_estimate_size_after_inlining (1, e->caller, node) + - e->caller->global.insns); + } - /* ??? Wrong for self recursive functions or cases where we decide to not - inline for different reasons, but it is not big deal as in that case - we will keep the body around, but we will also avoid some inlining. */ - if (!node->needed && !DECL_EXTERNAL (node->decl)) + /* ??? Wrong for non-trivially self recursive functions or cases where + we decide to not inline for different reasons, but it is not big deal + as in that case we will keep the body around, but we will also avoid + some inlining. */ + if (!node->needed && !DECL_EXTERNAL (node->decl) && !self_recursive) growth -= node->global.insns; node->global.estimated_growth = growth; @@ -906,8 +913,13 @@ cgraph_decide_inlining_of_small_functions (void) is not good idea so prohibit the recursive inlining. ??? When the frequencies are taken into account we might not need this - restriction. */ - if (!max_count) + restriction. + + We need to be cureful here, in some testcases, e.g. directivec.c in + libcpp, we can estimate self recursive function to have negative growth + for inlining completely. + */ + if (!edge->count) { where = edge->caller; while (where->global.inlined_to) |