From: Jan Hubicka Date: Sat, 30 Aug 2008 09:46:19 +0000 (+0200) Subject: ipa-inline.c (cgraph_estimate_growth): Discover self recursive functions. X-Git-Tag: releases/gcc-4.4.0~2771 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=76718c16d01e0ad14bb682f479f19702d093800d;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f8fcf7bbf416..b712a12dec98 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2008-08-30 Jan Hubicka + + * 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 PR bootstrap/37086 diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index a85a8a3be6b0..4c8096ae9b68 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)