ipa-inline.c (cgraph_estimate_growth): Discover self recursive functions.
* ipa-inline.c (cgraph_estimate_growth): Discover self recursive functions. (cgraph_decide_inlining_of_small_function): Use edge->count to detect profile presence locally. From-SVN: r139800
This commit is contained in:
parent
21bacb7e15
commit
76718c16d0
2 changed files with 28 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue