OSDN Git Service

Bring from lto-branch:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 28 Mar 2009 11:08:16 +0000 (11:08 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 28 Mar 2009 11:08:16 +0000 (11:08 +0000)
2008-09-03  Doug Kwan  <dougkwan@google.com>

* cgraphbuild.c (initialize_inline_failed): Use cgraph_inline_failed_t
enums instead of reason strings.
* cgraph.c (cgraph_create_edge): Same.
(cgraph_inline_failed_string): New function.
* cgraph.h (cgraph_inline_failed_t): New enum type.
(cgraph_inline_failed_string): New prototype.
(struct cgraph_edge): Change type of INLINED_FAILED from constant
char pointer to cgraph_inline_failed_t.
(cgraph_inline_p): Adjust prototype to use cgraph_inline_failed_t.
(cgraph_default_inline_p): Ditto.
* gcc/cgraphunit.c (cgraph_inline_p): Change type of parameter REASON
to cgraph_inline_failed_t pointer.
* cif-code.def: New file.
* ipa-inline.c (cgraph_mark_inline_edge): Use an enum instead of a
reason string.
(cgraph_check_inline_limits): Change type of REASON to pointer to
cgraph_inline_failed_t.  Replace reason strings with enums.
(cgraph_default_inline_p): Ditto.
(cgraph_recursive_inlining_p): Ditto.
(update_caller_keys): Change type of FAILED_REASON to
cgraph_inline_failed_t.
(cgraph_set_inline_failed): Change type of REASON to pointer to
cgraph_inline_failed_t.  Call cgraph_inline_failed_string to
convert enums to strings for text output.
(cgraph_decide_inlining_of_small_function): Change FAILED_REASON
to be of type cgraph_inline_failed_t.  Replace reason strings with
enums.  Call cgraph_inline_failed_string to covert enums
to strings for text output.
(cgraph_decide_inlining): Replace reason strings with enums.
(cgraph_decide_inlining_incrementally): Change type of FAILED_REASON
to cgraph_inline_failed_t type.  Call cgraph_inline_failed_string
for text output.
* tree-inline.c (expand_call_inline): Change type of REASON
to cgraph_inline_failed_t.  Replace reason strings with enums.
Call cgraph_inline_failed_string for text output.
* Makefile.in (CGRAPH_H): Add cif-code.def to dependencies.
(cgraph.o): Ditto.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145176 138bc75d-0d04-0410-961f-82ee72b054a4

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

index b700ee7..db8837c 100644 (file)
@@ -1,5 +1,48 @@
 2009-03-28  Jan Hubicka  <jh@suse.cz>
 
+       Bring from lto-branch:
+       2008-09-03  Doug Kwan  <dougkwan@google.com>
+
+       * cgraphbuild.c (initialize_inline_failed): Use cgraph_inline_failed_t
+       enums instead of reason strings.
+       * cgraph.c (cgraph_create_edge): Same.
+       (cgraph_inline_failed_string): New function.
+       * cgraph.h (cgraph_inline_failed_t): New enum type.
+       (cgraph_inline_failed_string): New prototype.
+       (struct cgraph_edge): Change type of INLINED_FAILED from constant
+       char pointer to cgraph_inline_failed_t.
+       (cgraph_inline_p): Adjust prototype to use cgraph_inline_failed_t.
+       (cgraph_default_inline_p): Ditto.
+       * gcc/cgraphunit.c (cgraph_inline_p): Change type of parameter REASON
+       to cgraph_inline_failed_t pointer.
+       * cif-code.def: New file.
+       * ipa-inline.c (cgraph_mark_inline_edge): Use an enum instead of a
+       reason string.
+       (cgraph_check_inline_limits): Change type of REASON to pointer to
+       cgraph_inline_failed_t.  Replace reason strings with enums.
+       (cgraph_default_inline_p): Ditto.
+       (cgraph_recursive_inlining_p): Ditto.
+       (update_caller_keys): Change type of FAILED_REASON to
+       cgraph_inline_failed_t.
+       (cgraph_set_inline_failed): Change type of REASON to pointer to
+       cgraph_inline_failed_t.  Call cgraph_inline_failed_string to
+       convert enums to strings for text output.
+       (cgraph_decide_inlining_of_small_function): Change FAILED_REASON
+       to be of type cgraph_inline_failed_t.  Replace reason strings with
+       enums.  Call cgraph_inline_failed_string to covert enums
+       to strings for text output.
+       (cgraph_decide_inlining): Replace reason strings with enums.
+       (cgraph_decide_inlining_incrementally): Change type of FAILED_REASON
+       to cgraph_inline_failed_t type.  Call cgraph_inline_failed_string
+       for text output.
+       * tree-inline.c (expand_call_inline): Change type of REASON
+       to cgraph_inline_failed_t.  Replace reason strings with enums.
+       Call cgraph_inline_failed_string for text output.
+       * Makefile.in (CGRAPH_H): Add cif-code.def to dependencies.
+       (cgraph.o): Ditto.
+
+2009-03-28  Jan Hubicka  <jh@suse.cz>
+
        * cgraph.c (cgraph_node, cgraph_remove_node, dump_cgraph_node,
        cgraph_clone_node): Remove master clone handling.
        (cgraph_is_master_clone, cgraph_master_clone): Remove.
index fa9ac3d..d17d6a9 100644 (file)
@@ -680,14 +680,13 @@ cgraph_create_edge (struct cgraph_node *caller, struct cgraph_node *callee,
     }
 
   if (!callee->analyzed)
-    edge->inline_failed = N_("function body not available");
+    edge->inline_failed = CIF_BODY_NOT_AVAILABLE;
   else if (callee->local.redefined_extern_inline)
-    edge->inline_failed = N_("redefined extern inline functions are not "
-                            "considered for inlining");
+    edge->inline_failed = CIF_REDEFINED_EXTERN_INLINE;
   else if (callee->local.inlinable)
-    edge->inline_failed = N_("function not considered for inlining");
+    edge->inline_failed = CIF_FUNCTION_NOT_CONSIDERED;
   else
-    edge->inline_failed = N_("function not inlinable");
+    edge->inline_failed = CIF_FUNCTION_NOT_INLINABLE;
 
   edge->aux = NULL;
 
@@ -1105,6 +1104,24 @@ cgraph_rtl_info (tree decl)
   return &node->rtl;
 }
 
+/* Return a string describing the failure REASON.  */
+
+const char*
+cgraph_inline_failed_string (cgraph_inline_failed_t reason)
+{
+#undef DEFCIFCODE
+#define DEFCIFCODE(code, string)       string,
+
+  static const char *cif_string_table[CIF_N_REASONS] = {
+#include "cif-code.def"
+  };
+
+  /* Signedness of an enum type is implementation defined, so cast it
+     to unsigned before testing. */
+  gcc_assert ((unsigned) reason < CIF_N_REASONS);
+  return cif_string_table[reason];
+}
+
 /* Return name of the node used in debug output.  */
 const char *
 cgraph_node_name (struct cgraph_node *node)
index 7f2cc7a..d2d310a 100644 (file)
@@ -189,6 +189,13 @@ struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous")))
   tree inline_decl;
 };
 
+#define DEFCIFCODE(code, string)       CIF_ ## code,
+/* Reasons for inlining failures.  */
+typedef enum {
+#include "cif-code.def"
+  CIF_N_REASONS
+} cgraph_inline_failed_t;
+
 struct cgraph_edge GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller")))
 {
   struct cgraph_node *caller;
@@ -199,9 +206,9 @@ struct cgraph_edge GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_call
   struct cgraph_edge *next_callee;
   gimple call_stmt;
   PTR GTY ((skip (""))) aux;
-  /* When NULL, inline this call.  When non-NULL, points to the explanation
-     why function was not inlined.  */
-  const char *inline_failed;
+  /* When equal to CIF_OK, inline this call.  Otherwise, points to the
+     explanation why function was not inlined.  */
+  cgraph_inline_failed_t inline_failed;
   /* Expected number of executions: calculated in profile.c.  */
   gcov_type count;
   /* Expected frequency of executions within the function. 
@@ -332,6 +339,7 @@ void cgraph_unnest_node (struct cgraph_node *);
 
 enum availability cgraph_function_body_availability (struct cgraph_node *);
 void cgraph_add_new_function (tree, bool);
+const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
 
 /* In cgraphunit.c  */
 void cgraph_finalize_function (tree, bool);
@@ -340,7 +348,7 @@ void cgraph_finalize_compilation_unit (void);
 void cgraph_optimize (void);
 void cgraph_mark_needed_node (struct cgraph_node *);
 void cgraph_mark_reachable_node (struct cgraph_node *);
-bool cgraph_inline_p (struct cgraph_edge *, const char **reason);
+bool cgraph_inline_p (struct cgraph_edge *, cgraph_inline_failed_t *reason);
 bool cgraph_preserve_function_body_p (tree);
 void verify_cgraph (void);
 void verify_cgraph_node (struct cgraph_node *);
@@ -449,7 +457,6 @@ varpool_next_static_initializer (struct varpool_node *node)
 
 /* In ipa-inline.c  */
 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
-bool cgraph_default_inline_p (struct cgraph_node *, const char **);
 unsigned int compute_inline_parameters (struct cgraph_node *);
 
 
index 75db875..f9bc620 100644 (file)
@@ -92,14 +92,13 @@ initialize_inline_failed (struct cgraph_node *node)
       gcc_assert (!e->callee->global.inlined_to);
       gcc_assert (e->inline_failed);
       if (node->local.redefined_extern_inline)
-       e->inline_failed = N_("redefined extern inline functions are not "
-                          "considered for inlining");
+       e->inline_failed = CIF_REDEFINED_EXTERN_INLINE;
       else if (!node->local.inlinable)
-       e->inline_failed = N_("function not inlinable");
+       e->inline_failed = CIF_FUNCTION_NOT_INLINABLE;
       else if (gimple_call_cannot_inline_p (e->call_stmt))
-       e->inline_failed = N_("mismatched arguments");
+       e->inline_failed = CIF_MISMATCHED_ARGUMENTS;
       else
-       e->inline_failed = N_("function not considered for inlining");
+       e->inline_failed = CIF_FUNCTION_NOT_CONSIDERED;
     }
 }
 
index 07998d4..d098db4 100644 (file)
@@ -1061,7 +1061,7 @@ cgraph_expand_function (struct cgraph_node *node)
 /* Return true when CALLER_DECL should be inlined into CALLEE_DECL.  */
 
 bool
-cgraph_inline_p (struct cgraph_edge *e, const char **reason)
+cgraph_inline_p (struct cgraph_edge *e, cgraph_inline_failed_t *reason)
 {
   *reason = e->inline_failed;
   return !e->inline_failed;
index d725f21..94e4576 100644 (file)
@@ -261,7 +261,7 @@ cgraph_mark_inline_edge (struct cgraph_edge *e, bool update_original,
     cgraph_redirect_edge_callee (e, cgraph_node (e->callee->inline_decl));
 
   gcc_assert (e->inline_failed);
-  e->inline_failed = NULL;
+  e->inline_failed = CIF_OK;
 
   if (!e->callee->global.inlined)
     DECL_POSSIBLY_INLINED (e->callee->decl) = true;
@@ -361,7 +361,7 @@ cgraph_estimate_growth (struct cgraph_node *node)
 
 static bool
 cgraph_check_inline_limits (struct cgraph_node *to, struct cgraph_node *what,
-                           const char **reason, bool one_only)
+                           cgraph_inline_failed_t *reason, bool one_only)
 {
   int times = 0;
   struct cgraph_edge *e;
@@ -396,7 +396,7 @@ cgraph_check_inline_limits (struct cgraph_node *to, struct cgraph_node *what,
       && newsize > limit)
     {
       if (reason)
-        *reason = N_("--param large-function-growth limit reached");
+        *reason = CIF_LARGE_FUNCTION_GROWTH_LIMIT;
       return false;
     }
 
@@ -411,7 +411,7 @@ cgraph_check_inline_limits (struct cgraph_node *to, struct cgraph_node *what,
       && inlined_stack > PARAM_VALUE (PARAM_LARGE_STACK_FRAME))
     {
       if (reason)
-        *reason = N_("--param large-stack-frame-growth limit reached");
+        *reason = CIF_LARGE_STACK_FRAME_GROWTH_LIMIT;
       return false;
     }
   return true;
@@ -419,8 +419,8 @@ 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, const char **reason)
+static bool
+cgraph_default_inline_p (struct cgraph_node *n, cgraph_inline_failed_t *reason)
 {
   tree decl = n->decl;
 
@@ -429,14 +429,14 @@ cgraph_default_inline_p (struct cgraph_node *n, const char **reason)
   if (!flag_inline_small_functions && !DECL_DECLARED_INLINE_P (decl))
     {
       if (reason)
-       *reason = N_("function not inline candidate");
+       *reason = CIF_FUNCTION_NOT_INLINE_CANDIDATE;
       return false;
     }
 
   if (!DECL_STRUCT_FUNCTION (decl)->cfg)
     {
       if (reason)
-       *reason = N_("function body not available");
+       *reason = CIF_BODY_NOT_AVAILABLE;
       return false;
     }
 
@@ -445,7 +445,7 @@ cgraph_default_inline_p (struct cgraph_node *n, const char **reason)
       if (n->global.insns >= MAX_INLINE_INSNS_SINGLE)
        {
          if (reason)
-           *reason = N_("--param max-inline-insns-single limit reached");
+           *reason = CIF_MAX_INLINE_INSNS_SINGLE_LIMIT;
          return false;
        }
     }
@@ -454,7 +454,7 @@ cgraph_default_inline_p (struct cgraph_node *n, const char **reason)
       if (n->global.insns >= MAX_INLINE_INSNS_AUTO)
        {
          if (reason)
-           *reason = N_("--param max-inline-insns-auto limit reached");
+           *reason = CIF_MAX_INLINE_INSNS_AUTO_LIMIT;
          return false;
        }
     }
@@ -469,7 +469,7 @@ cgraph_default_inline_p (struct cgraph_node *n, const char **reason)
 static bool
 cgraph_recursive_inlining_p (struct cgraph_node *to,
                             struct cgraph_node *what,
-                            const char **reason)
+                            cgraph_inline_failed_t *reason)
 {
   bool recursive;
   if (to->global.inlined_to)
@@ -480,7 +480,7 @@ cgraph_recursive_inlining_p (struct cgraph_node *to,
      not warn on it.  */
   if (recursive && reason)
     *reason = (what->local.disregard_inline_limits
-              ? N_("recursive inlining") : "");
+              ? CIF_RECURSIVE_INLINING : CIF_UNSPECIFIED);
   return recursive;
 }
 
@@ -566,7 +566,7 @@ update_caller_keys (fibheap_t heap, struct cgraph_node *node,
                    bitmap updated_nodes)
 {
   struct cgraph_edge *edge;
-  const char *failed_reason;
+  cgraph_inline_failed_t failed_reason;
 
   if (!node->local.inlinable || node->local.disregard_inline_limits
       || node->global.inlined_to)
@@ -790,12 +790,14 @@ cgraph_decide_recursive_inlining (struct cgraph_node *node,
 /* Set inline_failed for all callers of given function to REASON.  */
 
 static void
-cgraph_set_inline_failed (struct cgraph_node *node, const char *reason)
+cgraph_set_inline_failed (struct cgraph_node *node,
+                         cgraph_inline_failed_t reason)
 {
   struct cgraph_edge *e;
 
   if (dump_file)
-    fprintf (dump_file, "Inlining failed: %s\n", reason);
+    fprintf (dump_file, "Inlining failed: %s\n",
+            cgraph_inline_failed_string (reason));
   for (e = node->callers; e; e = e->next_caller)
     if (e->inline_failed)
       e->inline_failed = reason;
@@ -840,7 +842,7 @@ cgraph_decide_inlining_of_small_functions (void)
 {
   struct cgraph_node *node;
   struct cgraph_edge *edge;
-  const char *failed_reason;
+  cgraph_inline_failed_t failed_reason;
   fibheap_t heap = fibheap_new ();
   bitmap updated_nodes = BITMAP_ALLOC (NULL);
   int min_insns, max_insns;
@@ -887,7 +889,7 @@ cgraph_decide_inlining_of_small_functions (void)
       struct cgraph_node *where;
       int growth =
        cgraph_estimate_size_after_inlining (1, edge->caller, edge->callee);
-      const char *not_good = NULL;
+      cgraph_inline_failed_t not_good = CIF_OK;
 
       growth -= edge->caller->global.insns;
 
@@ -939,7 +941,8 @@ cgraph_decide_inlining_of_small_functions (void)
          if (where->global.inlined_to)
            {
              edge->inline_failed
-               = (edge->callee->local.disregard_inline_limits ? N_("recursive inlining") : "");
+               = (edge->callee->local.disregard_inline_limits
+                  ? CIF_RECURSIVE_INLINING : CIF_UNSPECIFIED);
              if (dump_file)
                fprintf (dump_file, " inline_failed:Recursive inlining performed only for function itself.\n");
              continue;
@@ -947,12 +950,12 @@ cgraph_decide_inlining_of_small_functions (void)
        }
 
       if (!cgraph_maybe_hot_edge_p (edge))
-       not_good = N_("call is unlikely and code size would grow");
+       not_good = CIF_UNLIKELY_CALL;
       if (!flag_inline_functions
          && !DECL_DECLARED_INLINE_P (edge->callee->decl))
-       not_good = N_("function not declared inline and code size would grow");
+       not_good = CIF_NOT_DECLARED_INLINED;
       if (optimize_function_for_size_p (DECL_STRUCT_FUNCTION(edge->caller->decl)))
-       not_good = N_("optimizing for size and code size would grow");
+       not_good = CIF_OPTIMIZING_FOR_SIZE;
       if (not_good && growth > 0 && cgraph_estimate_growth (edge->callee) > 0)
        {
           if (!cgraph_recursive_inlining_p (edge->caller, edge->callee,
@@ -960,7 +963,8 @@ cgraph_decide_inlining_of_small_functions (void)
            {
              edge->inline_failed = not_good;
              if (dump_file)
-               fprintf (dump_file, " inline_failed:%s.\n", edge->inline_failed);
+               fprintf (dump_file, " inline_failed:%s.\n",
+                        cgraph_inline_failed_string (edge->inline_failed));
            }
          continue;
        }
@@ -970,16 +974,18 @@ cgraph_decide_inlining_of_small_functions (void)
                                            &edge->inline_failed))
            {
              if (dump_file)
-               fprintf (dump_file, " inline_failed:%s.\n", edge->inline_failed);
+               fprintf (dump_file, " inline_failed:%s.\n",
+                        cgraph_inline_failed_string (edge->inline_failed));
            }
          continue;
        }
       if (!tree_can_inline_p (edge->caller->decl, edge->callee->decl))
        {
          gimple_call_set_cannot_inline (edge->call_stmt, true);
-         edge->inline_failed = N_("target specific option mismatch");
+         edge->inline_failed = CIF_TARGET_OPTION_MISMATCH;
          if (dump_file)
-           fprintf (dump_file, " inline_failed:%s.\n", edge->inline_failed);
+           fprintf (dump_file, " inline_failed:%s.\n",
+                    cgraph_inline_failed_string (edge->inline_failed));
          continue;
        }
       if (cgraph_recursive_inlining_p (edge->caller, edge->callee,
@@ -1005,7 +1011,8 @@ cgraph_decide_inlining_of_small_functions (void)
            {
              if (dump_file)
                fprintf (dump_file, " Not inlining into %s:%s.\n",
-                        cgraph_node_name (edge->caller), edge->inline_failed);
+                        cgraph_node_name (edge->caller),
+                        cgraph_inline_failed_string (edge->inline_failed));
              continue;
            }
          callee = edge->callee;
@@ -1053,7 +1060,7 @@ cgraph_decide_inlining_of_small_functions (void)
       if (!edge->callee->local.disregard_inline_limits && edge->inline_failed
           && !cgraph_recursive_inlining_p (edge->caller, edge->callee,
                                           &edge->inline_failed))
-       edge->inline_failed = N_("--param inline-unit-growth limit reached");
+       edge->inline_failed = CIF_INLINE_UNIT_GROWTH_LIMIT;
     }
 
   if (new_indirect_edges)
@@ -1163,7 +1170,7 @@ cgraph_decide_inlining (void)
             reason why inline failed.  */
          for (e = node->callers; e; e = e->next_caller)
            if (e->inline_failed)
-             e->inline_failed = N_("recursive inlining");
+             e->inline_failed = CIF_RECURSIVE_INLINING;
          if (dump_file)
            fprintf (dump_file, 
                     " Inlined for a net change of %+i insns.\n",
@@ -1289,7 +1296,7 @@ try_inline (struct cgraph_edge *e, enum inlining_mode mode, int depth)
                       cgraph_node_name (e->caller));
            }
          e->inline_failed = (e->callee->local.disregard_inline_limits
-                             ? N_("recursive inlining") : "");
+                             ? CIF_RECURSIVE_INLINING : CIF_UNSPECIFIED);
           return false;
        }
     }
@@ -1330,7 +1337,7 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node,
 {
   struct cgraph_edge *e;
   bool inlined = false;
-  const char *failed_reason;
+  cgraph_inline_failed_t failed_reason;
   enum inlining_mode old_mode;
 
 #ifdef ENABLE_CHECKING
@@ -1475,7 +1482,8 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node,
            if (dump_file)
              {
                indent_to (dump_file, depth);
-               fprintf (dump_file, "Not inlining: %s.\n", e->inline_failed);
+               fprintf (dump_file, "Not inlining: %s.\n",
+                        cgraph_inline_failed_string (e->inline_failed));
              }
            continue;
          }
index e6a2fb3..37d9098 100644 (file)
@@ -3153,7 +3153,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
   tree modify_dest;
   location_t saved_location;
   struct cgraph_edge *cg_edge;
-  const char *reason;
+  cgraph_inline_failed_t reason;
   basic_block return_block;
   edge e;
   gimple_stmt_iterator gsi, stmt_gsi;
@@ -3218,7 +3218,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
       cgraph_create_edge (id->dst_node, dest, stmt,
                          bb->count, CGRAPH_FREQ_BASE,
                          bb->loop_depth)->inline_failed
-       = N_("originally indirect function call not considered for inlining");
+       = CIF_ORIGINALLY_INDIRECT_CALL;
       if (dump_file)
        {
           fprintf (dump_file, "Created new direct edge to %s",
@@ -3241,18 +3241,19 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
          /* Avoid warnings during early inline pass. */
          && cgraph_global_info_ready)
        {
-         sorry ("inlining failed in call to %q+F: %s", fn, reason);
+         sorry ("inlining failed in call to %q+F: %s", fn,
+                cgraph_inline_failed_string (reason));
          sorry ("called from here");
        }
       else if (warn_inline && DECL_DECLARED_INLINE_P (fn)
               && !DECL_IN_SYSTEM_HEADER (fn)
-              && strlen (reason)
+              && reason != CIF_UNSPECIFIED
               && !lookup_attribute ("noinline", DECL_ATTRIBUTES (fn))
               /* Avoid warnings during early inline pass. */
               && cgraph_global_info_ready)
        {
          warning (OPT_Winline, "inlining failed in call to %q+F: %s",
-                  fn, reason);
+                  fn, cgraph_inline_failed_string (reason));
          warning (OPT_Winline, "called from here");
        }
       goto egress;