summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2010-05-29 07:31:11 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2010-05-29 07:31:11 +0000
commita70a5e2c5886c7e188ccb1be38de030808d5bf4b (patch)
tree2bccbc03becb82b7caf9f75dcea83ae37194f46b
parent4966cbe25818acad1caf27ba439339875099c231 (diff)
downloadgcc-a70a5e2c5886c7e188ccb1be38de030808d5bf4b.tar.gz
* 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. * 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
-rw-r--r--gcc/ChangeLog16
-rw-r--r--gcc/cgraph.c17
-rw-r--r--gcc/cgraph.h6
-rw-r--r--gcc/cgraphunit.c42
-rw-r--r--gcc/ipa-cp.c2
-rw-r--r--gcc/omp-low.c18
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ipa-cp-1.c2
8 files changed, 54 insertions, 53 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 555b3634b0a..60983962deb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 7bfb9bc3d81..04ff9c98f20 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -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);
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 8772cebdcec..b4ce531f7b3 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -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);
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index d4a142b2bd7..e7e9e29659e 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -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;
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 5c953b4c4ba..0efdb47b315 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -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;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 74797b8aa0c..12bd4c65608 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c5b13d63222..1dc4528c160 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ipa-cp-1.c b/gcc/testsuite/gcc.dg/tree-ssa/ipa-cp-1.c
index b9c67a62609..7918eb7562d 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ipa-cp-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ipa-cp-1.c
@@ -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" } } */