ipa-inline.c (cgraph_edge_badness): Update comments.
authorJosh Conner <jconner@apple.com>
Thu, 28 Jul 2005 17:14:57 +0000 (17:14 +0000)
committerJosh Conner <jconner@gcc.gnu.org>
Thu, 28 Jul 2005 17:14:57 +0000 (17:14 +0000)
        * ipa-inline.c (cgraph_edge_badness): Update comments.  Invert shift
        direction of badness if negative.
        (cgraph_default_inline_p): Add reason to parameters, and assign it
        a value.
        (cgraph_decide_inlining_of_small_functions): New parameter in call
        to cgraph_default_inline_p.
        (cgraph_decide_inlining_incrementally): Likewise.
        * cgraphunit.c (decide_is_function_needed): Likewise.
        * cgraph.h (cgraph_default_inline_p): Likewise.

From-SVN: r102497

gcc/ChangeLog
gcc/cgraph.h
gcc/cgraphunit.c
gcc/ipa-inline.c

index 25772a9f6a6d3c7fbf20c522a806012151d1344b..5b081e1118bbf6c2c2a58e91e97bc3557a1f0157 100644 (file)
@@ -1,3 +1,15 @@
+2005-07-28  Josh Conner  <jconner@apple.com>
+
+       * ipa-inline.c (cgraph_edge_badness): Update comments.  Invert shift
+       direction of badness if negative.
+       (cgraph_default_inline_p): Add reason to parameters, and assign it
+       a value.
+       (cgraph_decide_inlining_of_small_functions): New parameter in call
+       to cgraph_default_inline_p.
+       (cgraph_decide_inlining_incrementally): Likewise.
+       * cgraphunit.c (decide_is_function_needed): Likewise.
+       * cgraph.h (cgraph_default_inline_p): Likewise.
+
 2005-07-28  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        * builtins.c: Fix comment typo(s).
index d063d41906dd4bead477d291ad8dadbca73bd720..4e2a4c17d9d39bb9823430e078e0c94db621eb03 100644 (file)
@@ -287,5 +287,5 @@ int cgraph_postorder (struct cgraph_node **);
 bool cgraph_decide_inlining_incrementally (struct cgraph_node *, bool);
 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool);
 void cgraph_mark_inline_edge (struct cgraph_edge *);
-bool cgraph_default_inline_p (struct cgraph_node *);
+bool cgraph_default_inline_p (struct cgraph_node *, const char **);
 #endif  /* GCC_CGRAPH_H  */
index 7b126cc6f89486c437f858b2b527d93867f95d7c..f8f864c11f811352326964df50b4eb2c36f4b41b 100644 (file)
@@ -248,7 +248,7 @@ decide_is_function_needed (struct cgraph_node *node, tree decl)
          /* When declared inline, defer even the uninlinable functions.
             This allows them to be eliminated when unused.  */
          && !DECL_DECLARED_INLINE_P (decl) 
-         && (!node->local.inlinable || !cgraph_default_inline_p (node))))
+         && (!node->local.inlinable || !cgraph_default_inline_p (node, NULL))))
     return true;
 
   return false;
index df57ccce0530703af6ed06d32b0e9a7313ccb169..0797e773c2a87ca92e9da3c1dbafcc18c8697e16 100644 (file)
@@ -277,14 +277,42 @@ cgraph_check_inline_limits (struct cgraph_node *to, struct cgraph_node *what,
 /* Return true when function N is small enough to be inlined.  */
 
 bool
-cgraph_default_inline_p (struct cgraph_node *n)
+cgraph_default_inline_p (struct cgraph_node *n, const char **reason)
 {
-  if (!DECL_INLINE (n->decl) || !DECL_SAVED_TREE (n->decl))
-    return false;
+  if (!DECL_INLINE (n->decl))
+    {
+      if (reason)
+       *reason = N_("function not inlinable");
+      return false;
+    }
+
+  if (!DECL_SAVED_TREE (n->decl))
+    {
+      if (reason)
+       *reason = N_("function body not available");
+      return false;
+    }
+
   if (DECL_DECLARED_INLINE_P (n->decl))
-    return n->global.insns < MAX_INLINE_INSNS_SINGLE;
+    {
+      if (n->global.insns >= MAX_INLINE_INSNS_SINGLE)
+       {
+         if (reason)
+           *reason = N_("--param max-inline-insns-single limit reached");
+         return false;
+       }
+    }
   else
-    return n->global.insns < MAX_INLINE_INSNS_AUTO;
+    {
+      if (n->global.insns >= MAX_INLINE_INSNS_AUTO)
+       {
+         if (reason)
+           *reason = N_("--param max-inline-insns-auto limit reached");
+         return false;
+       }
+    }
+
+  return true;
 }
 
 /* Return true when inlining WHAT would create recursive inlining.
@@ -326,15 +354,9 @@ cgraph_maybe_hot_edge_p (struct cgraph_edge *edge)
    metrics may accurately depend on values such as number of inlinable callers
    of the function or function body size.
 
-   For the moment we use estimated growth caused by inlining callee into all
-   it's callers for driving the inlining but once we have loop depth or
-   frequency information readily available we should do better.
-
    With profiling we use number of executions of each edge to drive the cost.
    We also should distinguish hot and cold calls where the cold calls are
    inlined into only when code size is overall improved.  
-   
-   Value INT_MAX can be returned to prevent function from being inlined.
    */
 
 static int
@@ -355,8 +377,12 @@ cgraph_edge_badness (struct cgraph_edge *edge)
   {
     int nest = MIN (edge->loop_nest, 8);
     int badness = cgraph_estimate_growth (edge->callee) * 256;
-                   
-    badness >>= nest;
+
+    /* Decrease badness if call is nested.  */
+    if (badness > 0)    
+      badness >>= nest;
+    else
+      badness <<= nest;
 
     /* Make recursive inlining happen always after other inlining is done.  */
     if (cgraph_recursive_inlining_p (edge->caller, edge->callee, NULL))
@@ -609,6 +635,7 @@ cgraph_decide_inlining_of_small_functions (void)
 {
   struct cgraph_node *node;
   struct cgraph_edge *edge;
+  const char *failed_reason;
   fibheap_t heap = fibheap_new ();
   bitmap updated_nodes = BITMAP_ALLOC (NULL);
 
@@ -626,10 +653,9 @@ cgraph_decide_inlining_of_small_functions (void)
        fprintf (dump_file, "Considering inline candidate %s.\n", cgraph_node_name (node));
 
       node->global.estimated_growth = INT_MIN;
-      if (!cgraph_default_inline_p (node))
+      if (!cgraph_default_inline_p (node, &failed_reason))
        {
-         cgraph_set_inline_failed (node,
-           N_("--param max-inline-insns-single limit reached"));
+         cgraph_set_inline_failed (node, failed_reason);
          continue;
        }
 
@@ -708,13 +734,11 @@ cgraph_decide_inlining_of_small_functions (void)
            }
          continue;
        }
-      if (!cgraph_default_inline_p (edge->callee))
+      if (!cgraph_default_inline_p (edge->callee, &edge->inline_failed))
        {
           if (!cgraph_recursive_inlining_p (edge->caller, edge->callee,
                                            &edge->inline_failed))
            {
-             edge->inline_failed = 
-               N_("--param max-inline-insns-single limit reached after inlining into the callee");
              if (dump_file)
                fprintf (dump_file, " inline_failed:%s.\n", edge->inline_failed);
            }
@@ -954,6 +978,7 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early)
 {
   struct cgraph_edge *e;
   bool inlined = false;
+  const char *failed_reason;
 
   /* First of all look for always inline functions.  */
   for (e = node->callees; e; e = e->next_callee)
@@ -984,7 +1009,7 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early)
          && cgraph_check_inline_limits (node, e->callee, &e->inline_failed)
          && DECL_SAVED_TREE (e->callee->decl))
        {
-         if (cgraph_default_inline_p (e->callee))
+         if (cgraph_default_inline_p (e->callee, &failed_reason))
            {
              if (dump_file && early)
                 fprintf (dump_file, "  Early inlining %s into %s\n",
@@ -993,8 +1018,7 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early)
              inlined = true;
            }
          else if (!early)
-           e->inline_failed
-             = N_("--param max-inline-insns-single limit reached");
+           e->inline_failed = failed_reason;
        }
   if (early && inlined)
     {