Commit 036546e5 by Jan Hubicka Committed by Jan Hubicka

cgraph.c (clone_function_name): Take SUFFIX argument; export.

	* 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.

From-SVN: r160016
parent 6c608111
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> 2010-05-29 Steven Bosscher <steven@gcc.gnu.org>
* vec.h: Include statistics.h * vec.h: Include statistics.h
......
...@@ -2143,24 +2143,26 @@ cgraph_clone_node (struct cgraph_node *n, tree decl, gcov_type count, int freq, ...@@ -2143,24 +2143,26 @@ cgraph_clone_node (struct cgraph_node *n, tree decl, gcov_type count, int freq,
return new_node; 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 GTY(()) unsigned int clone_fn_id_num;
static tree tree
clone_function_name (tree decl) clone_function_name (tree decl, const char *suffix)
{ {
tree name = DECL_ASSEMBLER_NAME (decl); tree name = DECL_ASSEMBLER_NAME (decl);
size_t len = IDENTIFIER_LENGTH (name); size_t len = IDENTIFIER_LENGTH (name);
char *tmp_name, *prefix; char *tmp_name, *prefix;
prefix = XALLOCAVEC (char, len + strlen ("_clone") + 1); prefix = XALLOCAVEC (char, len + strlen (suffix) + 2);
memcpy (prefix, IDENTIFIER_POINTER (name), len); memcpy (prefix, IDENTIFIER_POINTER (name), len);
strcpy (prefix + len, "_clone"); strcpy (prefix + len + 1, suffix);
#ifndef NO_DOT_IN_LABEL #ifndef NO_DOT_IN_LABEL
prefix[len] = '.'; prefix[len] = '.';
#elif !defined NO_DOLLAR_IN_LABEL #elif !defined NO_DOLLAR_IN_LABEL
prefix[len] = '$'; prefix[len] = '$';
#else
prefix[len] = '_';
#endif #endif
ASM_FORMAT_PRIVATE_NAME (tmp_name, prefix, clone_fn_id_num++); ASM_FORMAT_PRIVATE_NAME (tmp_name, prefix, clone_fn_id_num++);
return get_identifier (tmp_name); return get_identifier (tmp_name);
...@@ -2176,7 +2178,8 @@ struct cgraph_node * ...@@ -2176,7 +2178,8 @@ struct cgraph_node *
cgraph_create_virtual_clone (struct cgraph_node *old_node, cgraph_create_virtual_clone (struct cgraph_node *old_node,
VEC(cgraph_edge_p,heap) *redirect_callers, VEC(cgraph_edge_p,heap) *redirect_callers,
VEC(ipa_replace_map_p,gc) *tree_map, 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; tree old_decl = old_node->decl;
struct cgraph_node *new_node = NULL; struct cgraph_node *new_node = NULL;
...@@ -2197,7 +2200,7 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node, ...@@ -2197,7 +2200,7 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node,
DECL_STRUCT_FUNCTION (new_decl) = NULL; DECL_STRUCT_FUNCTION (new_decl) = NULL;
/* Generate a new name for the new version. */ /* 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_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
SET_DECL_RTL (new_decl, NULL); SET_DECL_RTL (new_decl, NULL);
......
...@@ -588,12 +588,14 @@ const char* cgraph_inline_failed_string (cgraph_inline_failed_t); ...@@ -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, struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
VEC(cgraph_edge_p,heap)*, VEC(cgraph_edge_p,heap)*,
VEC(ipa_replace_map_p,gc)* tree_map, 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_nothrow_flag (struct cgraph_node *, bool);
void cgraph_set_readonly_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_pure_flag (struct cgraph_node *, bool);
void cgraph_set_looping_const_or_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 */ /* In cgraphunit.c */
void cgraph_finalize_function (tree, bool); void cgraph_finalize_function (tree, bool);
...@@ -613,7 +615,7 @@ void init_cgraph (void); ...@@ -613,7 +615,7 @@ void init_cgraph (void);
struct cgraph_node *cgraph_function_versioning (struct cgraph_node *, struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
VEC(cgraph_edge_p,heap)*, VEC(cgraph_edge_p,heap)*,
VEC(ipa_replace_map_p,gc)*, VEC(ipa_replace_map_p,gc)*,
bitmap); bitmap, const char *);
void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap); void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap);
struct cgraph_node *save_inline_function_body (struct cgraph_node *); struct cgraph_node *save_inline_function_body (struct cgraph_node *);
void record_references_in_initializer (tree, bool); void record_references_in_initializer (tree, bool);
......
...@@ -2106,10 +2106,9 @@ static struct cgraph_node * ...@@ -2106,10 +2106,9 @@ static struct cgraph_node *
cgraph_copy_node_for_versioning (struct cgraph_node *old_version, cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
tree new_decl, tree new_decl,
VEC(cgraph_edge_p,heap) *redirect_callers) VEC(cgraph_edge_p,heap) *redirect_callers)
{ {
struct cgraph_node *new_version; struct cgraph_node *new_version;
struct cgraph_edge *e; struct cgraph_edge *e;
struct cgraph_edge *next_callee;
unsigned i; unsigned i;
gcc_assert (old_version); gcc_assert (old_version);
...@@ -2118,34 +2117,24 @@ cgraph_copy_node_for_versioning (struct cgraph_node *old_version, ...@@ -2118,34 +2117,24 @@ cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
new_version->analyzed = true; new_version->analyzed = true;
new_version->local = old_version->local; 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->global = old_version->global;
new_version->rtl = new_version->rtl; new_version->rtl = new_version->rtl;
new_version->reachable = true; new_version->reachable = true;
new_version->count = old_version->count; new_version->count = old_version->count;
/* Clone the old node callees. Recursive calls are for (e = old_version->callees; e; e=e->next_callee)
also cloned. */ cgraph_clone_edge (e, new_version, e->call_stmt,
for (e = old_version->callees;e; e=e->next_callee) e->lto_stmt_uid, REG_BR_PROB_BASE,
{ CGRAPH_FREQ_BASE,
cgraph_clone_edge (e, new_version, e->call_stmt, e->loop_nest, true);
e->lto_stmt_uid, REG_BR_PROB_BASE, for (e = old_version->indirect_calls; e; e=e->next_callee)
CGRAPH_FREQ_BASE, cgraph_clone_edge (e, new_version, e->call_stmt,
e->loop_nest, true); e->lto_stmt_uid, REG_BR_PROB_BASE,
} CGRAPH_FREQ_BASE,
/* Fix recursive calls. e->loop_nest, true);
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 (i = 0; VEC_iterate (cgraph_edge_p, redirect_callers, i, e); i++) 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 /* Redirect calls to the old version node to point to its new
...@@ -2175,7 +2164,8 @@ struct cgraph_node * ...@@ -2175,7 +2164,8 @@ struct cgraph_node *
cgraph_function_versioning (struct cgraph_node *old_version_node, cgraph_function_versioning (struct cgraph_node *old_version_node,
VEC(cgraph_edge_p,heap) *redirect_callers, VEC(cgraph_edge_p,heap) *redirect_callers,
VEC (ipa_replace_map_p,gc)* tree_map, 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; tree old_decl = old_version_node->decl;
struct cgraph_node *new_version_node = NULL; struct cgraph_node *new_version_node = NULL;
......
...@@ -1186,7 +1186,7 @@ ipcp_insert_stage (void) ...@@ -1186,7 +1186,7 @@ ipcp_insert_stage (void)
new versioned node. */ new versioned node. */
node1 = node1 =
cgraph_create_virtual_clone (node, redirect_callers, replace_trees, cgraph_create_virtual_clone (node, redirect_callers, replace_trees,
args_to_skip); args_to_skip, "clone");
args_to_skip = NULL; args_to_skip = NULL;
VEC_free (cgraph_edge_p, heap, redirect_callers); VEC_free (cgraph_edge_p, heap, redirect_callers);
replace_trees = NULL; replace_trees = NULL;
......
...@@ -1531,22 +1531,8 @@ static GTY(()) unsigned int tmp_ompfn_id_num; ...@@ -1531,22 +1531,8 @@ static GTY(()) unsigned int tmp_ompfn_id_num;
static tree static tree
create_omp_child_function_name (bool task_copy) create_omp_child_function_name (bool task_copy)
{ {
tree name = DECL_ASSEMBLER_NAME (current_function_decl); return (clone_function_name (current_function_decl,
size_t len = IDENTIFIER_LENGTH (name); task_copy ? "_omp_cpyfn" : "_omp_fn"));
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);
} }
/* Build a decl for the omp child function. It'll not contain a body /* Build a decl for the omp child function. It'll not contain a body
......
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> 2010-05-28 Sebastian Pop <sebastian.pop@amd.com>
* gcc.dg/vect/vect-outer-fir-lb.c: Un-XFAIL-ed. * gcc.dg/vect/vect-outer-fir-lb.c: Un-XFAIL-ed.
......
...@@ -12,5 +12,5 @@ main() ...@@ -12,5 +12,5 @@ main()
very_long_function (1); very_long_function (1);
} }
/* One appereance for dump, one self recursive call and one call from main. */ /* 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" } } */ /* { dg-final { cleanup-tree-dump "optimized" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment