]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* cgraph.c (clone_function_name): Take SUFFIX argument; export.
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 29 May 2010 07:31:11 +0000 (07:31 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 29 May 2010 07:31:11 +0000 (07:31 +0000)
(cgraph_create_virtual_clone): Take SUFFIX argument; udpate
use of clone_function_name.
* cgraph.h (cgraph_create_virtual_clone,
cgraph_function_versioning): update prototypes.
(clone_function_name): Declare.
* ipa-cp.c (ipcp_insert_stage): Update call of
cgraph_create_virtual_clone.
* omp-low.c (create_omp_child_function_name): Use
cgraph_create_virtual_clone.
* cgraphunit.c (cgraph_copy_node_for_versioning): Fix edges updating.
(cgraph_function_versioning): Take SUFFIX argument; produce new name
and make decl local.

* gcc.dg/tree-ssa/ipa-cp-1.c: Update testcase.

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

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraph.h
gcc/cgraphunit.c
gcc/ipa-cp.c
gcc/omp-low.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ipa-cp-1.c

index 555b3634b0a4bb6a2ccb9c264fdc07011ebefc69..60983962deb48e9994a4ffb0ad8dc8a190021a6d 100644 (file)
@@ -1,3 +1,19 @@
+2010-05-29  Jan Hubicka  <jh@suse.cz>
+
+       * cgraph.c (clone_function_name): Take SUFFIX argument; export.
+       (cgraph_create_virtual_clone): Take SUFFIX argument; udpate
+       use of clone_function_name.
+       * cgraph.h (cgraph_create_virtual_clone, 
+       cgraph_function_versioning): update prototypes.
+       (clone_function_name): Declare.
+       * ipa-cp.c (ipcp_insert_stage): Update call of
+       cgraph_create_virtual_clone.
+       * omp-low.c (create_omp_child_function_name): Use
+       cgraph_create_virtual_clone.
+       * cgraphunit.c (cgraph_copy_node_for_versioning): Fix edges updating.
+       (cgraph_function_versioning): Take SUFFIX argument; produce new name
+       and make decl local.
+
 2010-05-29  Steven Bosscher  <steven@gcc.gnu.org>
 
        * vec.h: Include statistics.h
index 7bfb9bc3d8117b2ad10c203e31d4cea73c78f212..04ff9c98f20e8fe10ea489cdbc3be608f607fcf7 100644 (file)
@@ -2143,24 +2143,26 @@ cgraph_clone_node (struct cgraph_node *n, tree decl, gcov_type count, int freq,
   return new_node;
 }
 
-/* Create a new name for omp child function.  Returns an identifier.  */
+/* Create a new name for clone of DECL, add SUFFIX.  Returns an identifier.  */
 
 static GTY(()) unsigned int clone_fn_id_num;
 
-static tree
-clone_function_name (tree decl)
+tree
+clone_function_name (tree decl, const char *suffix)
 {
   tree name = DECL_ASSEMBLER_NAME (decl);
   size_t len = IDENTIFIER_LENGTH (name);
   char *tmp_name, *prefix;
 
-  prefix = XALLOCAVEC (char, len + strlen ("_clone") + 1);
+  prefix = XALLOCAVEC (char, len + strlen (suffix) + 2);
   memcpy (prefix, IDENTIFIER_POINTER (name), len);
-  strcpy (prefix + len, "_clone");
+  strcpy (prefix + len + 1, suffix);
 #ifndef NO_DOT_IN_LABEL
   prefix[len] = '.';
 #elif !defined NO_DOLLAR_IN_LABEL
   prefix[len] = '$';
+#else
+  prefix[len] = '_';
 #endif
   ASM_FORMAT_PRIVATE_NAME (tmp_name, prefix, clone_fn_id_num++);
   return get_identifier (tmp_name);
@@ -2176,7 +2178,8 @@ struct cgraph_node *
 cgraph_create_virtual_clone (struct cgraph_node *old_node,
                             VEC(cgraph_edge_p,heap) *redirect_callers,
                             VEC(ipa_replace_map_p,gc) *tree_map,
-                            bitmap args_to_skip)
+                            bitmap args_to_skip,
+                            const char * suffix)
 {
   tree old_decl = old_node->decl;
   struct cgraph_node *new_node = NULL;
@@ -2197,7 +2200,7 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node,
   DECL_STRUCT_FUNCTION (new_decl) = NULL;
 
   /* Generate a new name for the new version. */
-  DECL_NAME (new_decl) = clone_function_name (old_decl);
+  DECL_NAME (new_decl) = clone_function_name (old_decl, suffix);
   SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
   SET_DECL_RTL (new_decl, NULL);
 
index 8772cebdcec1ebfd2d8a07df1fbe98c00a0acbf9..b4ce531f7b37ae913f9fe1eef7249c1ea10f6351 100644 (file)
@@ -588,12 +588,14 @@ const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
                                                  VEC(cgraph_edge_p,heap)*,
                                                  VEC(ipa_replace_map_p,gc)* tree_map,
-                                                 bitmap args_to_skip);
+                                                 bitmap args_to_skip,
+                                                 const char *clone_name);
 
 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
 void cgraph_set_readonly_flag (struct cgraph_node *, bool);
 void cgraph_set_pure_flag (struct cgraph_node *, bool);
 void cgraph_set_looping_const_or_pure_flag (struct cgraph_node *, bool);
+tree clone_function_name (tree decl, const char *);
 
 /* In cgraphunit.c  */
 void cgraph_finalize_function (tree, bool);
@@ -613,7 +615,7 @@ void init_cgraph (void);
 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
                                                VEC(cgraph_edge_p,heap)*,
                                                VEC(ipa_replace_map_p,gc)*,
-                                               bitmap);
+                                               bitmap, const char *);
 void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap);
 struct cgraph_node *save_inline_function_body (struct cgraph_node *);
 void record_references_in_initializer (tree, bool);
index d4a142b2bd7a4cefea02b5572e737c06f0ee878f..e7e9e29659e2ac4903c903b18be7ca4d7fcf20d3 100644 (file)
@@ -2106,10 +2106,9 @@ static struct cgraph_node *
 cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
                                 tree new_decl,
                                 VEC(cgraph_edge_p,heap) *redirect_callers)
- {
+{
    struct cgraph_node *new_version;
    struct cgraph_edge *e;
-   struct cgraph_edge *next_callee;
    unsigned i;
 
    gcc_assert (old_version);
@@ -2118,34 +2117,24 @@ cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
 
    new_version->analyzed = true;
    new_version->local = old_version->local;
+   new_version->local.externally_visible = false;
+   new_version->local.local = true;
+   new_version->local.vtable_method = false;
    new_version->global = old_version->global;
    new_version->rtl = new_version->rtl;
    new_version->reachable = true;
    new_version->count = old_version->count;
 
-   /* Clone the old node callees.  Recursive calls are
-      also cloned.  */
-   for (e = old_version->callees;e; e=e->next_callee)
-     {
-       cgraph_clone_edge (e, new_version, e->call_stmt,
-                         e->lto_stmt_uid, REG_BR_PROB_BASE,
-                         CGRAPH_FREQ_BASE,
-                         e->loop_nest, true);
-     }
-   /* Fix recursive calls.
-      If OLD_VERSION has a recursive call after the
-      previous edge cloning, the new version will have an edge
-      pointing to the old version, which is wrong;
-      Redirect it to point to the new version. */
-   for (e = new_version->callees ; e; e = next_callee)
-     {
-       next_callee = e->next_callee;
-       if (e->callee == old_version)
-        cgraph_redirect_edge_callee (e, new_version);
-
-       if (!next_callee)
-        break;
-     }
+   for (e = old_version->callees; e; e=e->next_callee)
+     cgraph_clone_edge (e, new_version, e->call_stmt,
+                       e->lto_stmt_uid, REG_BR_PROB_BASE,
+                       CGRAPH_FREQ_BASE,
+                       e->loop_nest, true);
+   for (e = old_version->indirect_calls; e; e=e->next_callee)
+     cgraph_clone_edge (e, new_version, e->call_stmt,
+                       e->lto_stmt_uid, REG_BR_PROB_BASE,
+                       CGRAPH_FREQ_BASE,
+                       e->loop_nest, true);
    for (i = 0; VEC_iterate (cgraph_edge_p, redirect_callers, i, e); i++)
      {
        /* Redirect calls to the old version node to point to its new
@@ -2175,7 +2164,8 @@ struct cgraph_node *
 cgraph_function_versioning (struct cgraph_node *old_version_node,
                            VEC(cgraph_edge_p,heap) *redirect_callers,
                            VEC (ipa_replace_map_p,gc)* tree_map,
-                           bitmap args_to_skip)
+                           bitmap args_to_skip,
+                           const char *clone_name)
 {
   tree old_decl = old_version_node->decl;
   struct cgraph_node *new_version_node = NULL;
index 5c953b4c4ba41d570e8ed73043ae49b29a473d0f..0efdb47b315482c6676da716d1454697cdac9b5f 100644 (file)
@@ -1186,7 +1186,7 @@ ipcp_insert_stage (void)
          new versioned node.  */
       node1 =
        cgraph_create_virtual_clone (node, redirect_callers, replace_trees,
-                                    args_to_skip);
+                                    args_to_skip, "clone");
       args_to_skip = NULL;
       VEC_free (cgraph_edge_p, heap, redirect_callers);
       replace_trees = NULL;
index 74797b8aa0cea3494fe5c21a2404c8c3648ff108..12bd4c6560876101adac9506c107763608da51d2 100644 (file)
@@ -1531,22 +1531,8 @@ static GTY(()) unsigned int tmp_ompfn_id_num;
 static tree
 create_omp_child_function_name (bool task_copy)
 {
-  tree name = DECL_ASSEMBLER_NAME (current_function_decl);
-  size_t len = IDENTIFIER_LENGTH (name);
-  char *tmp_name, *prefix;
-  const char *suffix;
-
-  suffix = task_copy ? "_omp_cpyfn" : "_omp_fn";
-  prefix = XALLOCAVEC (char, len + strlen (suffix) + 1);
-  memcpy (prefix, IDENTIFIER_POINTER (name), len);
-  strcpy (prefix + len, suffix);
-#ifndef NO_DOT_IN_LABEL
-  prefix[len] = '.';
-#elif !defined NO_DOLLAR_IN_LABEL
-  prefix[len] = '$';
-#endif
-  ASM_FORMAT_PRIVATE_NAME (tmp_name, prefix, tmp_ompfn_id_num++);
-  return get_identifier (tmp_name);
+  return (clone_function_name (current_function_decl,
+                              task_copy ? "_omp_cpyfn" : "_omp_fn"));
 }
 
 /* Build a decl for the omp child function.  It'll not contain a body
index c5b13d632220ea23815043c273464c3f5dbb99ec..1dc4528c16068ddcce94317d30741581f1149ab4 100644 (file)
@@ -1,3 +1,7 @@
+2010-05-29  Jan Hubicka  <jh@suse.cz>
+
+       * gcc.dg/tree-ssa/ipa-cp-1.c: Update testcase.
+
 2010-05-28  Sebastian Pop  <sebastian.pop@amd.com>
 
        * gcc.dg/vect/vect-outer-fir-lb.c: Un-XFAIL-ed.
index b9c67a6260976868b874d533676dae8c5b21edbc..7918eb7562d6fe9c6e913487311940edf409aa02 100644 (file)
@@ -12,5 +12,5 @@ main()
   very_long_function (1);
 }
 /* One appereance for dump, one self recursive call and one call from main.  */
-/* { dg-final { scan-tree-dump-times "very_long_function.clone.0 \\(\\)" 3 "optimized"} } */
+/* { dg-final { scan-tree-dump-times "very_long_function.constprop.0 \\(\\)" 3 "optimized"} } */
 /* { dg-final { cleanup-tree-dump "optimized" } } */