Commit 76718c16 by Jan Hubicka Committed by Jan Hubicka

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
parent 21bacb7e
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> 2008-08-29 Joseph Myers <joseph@codesourcery.com>
PR bootstrap/37086 PR bootstrap/37086
......
...@@ -318,18 +318,25 @@ cgraph_estimate_growth (struct cgraph_node *node) ...@@ -318,18 +318,25 @@ cgraph_estimate_growth (struct cgraph_node *node)
{ {
int growth = 0; int growth = 0;
struct cgraph_edge *e; struct cgraph_edge *e;
bool self_recursive = false;
if (node->global.estimated_growth != INT_MIN) if (node->global.estimated_growth != INT_MIN)
return node->global.estimated_growth; return node->global.estimated_growth;
for (e = node->callers; e; e = e->next_caller) for (e = node->callers; e; e = e->next_caller)
if (e->inline_failed) {
growth += (cgraph_estimate_size_after_inlining (1, e->caller, node) if (e->caller == node)
- e->caller->global.insns); 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 /* ??? Wrong for non-trivially self recursive functions or cases where
inline for different reasons, but it is not big deal as in that case we decide to not inline for different reasons, but it is not big deal
we will keep the body around, but we will also avoid some inlining. */ as in that case we will keep the body around, but we will also avoid
if (!node->needed && !DECL_EXTERNAL (node->decl)) some inlining. */
if (!node->needed && !DECL_EXTERNAL (node->decl) && !self_recursive)
growth -= node->global.insns; growth -= node->global.insns;
node->global.estimated_growth = growth; node->global.estimated_growth = growth;
...@@ -906,8 +913,13 @@ cgraph_decide_inlining_of_small_functions (void) ...@@ -906,8 +913,13 @@ cgraph_decide_inlining_of_small_functions (void)
is not good idea so prohibit the recursive inlining. is not good idea so prohibit the recursive inlining.
??? When the frequencies are taken into account we might not need this ??? When the frequencies are taken into account we might not need this
restriction. */ restriction.
if (!max_count)
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; where = edge->caller;
while (where->global.inlined_to) while (where->global.inlined_to)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment