]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa-inline.c (cgraph_estimate_growth): Discover self recursive functions.
authorJan Hubicka <jh@suse.cz>
Sat, 30 Aug 2008 09:46:19 +0000 (11:46 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sat, 30 Aug 2008 09:46:19 +0000 (09:46 +0000)
* 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

gcc/ChangeLog
gcc/ipa-inline.c

index f8fcf7bbf416bfaa2a95665b4a10578505c24555..b712a12dec985259478369af0f9bd8118fb1e734 100644 (file)
@@ -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
index a85a8a3be6b0562fefe566dc473a7d536d38b961..4c8096ae9b68ab188c73711aedf19558da9ae967 100644 (file)
@@ -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)