Commit 702d8703 by Jan Hubicka Committed by Jan Hubicka

re PR lto/54095 (Unnecessary static variable renaming)

	PR lto/54095
	* cgraph.c (cgraph_make_node_local_1): Se unique_name.
	* cgraph.h (symtab_node_base): Add unique_name.
	* lto-cgraph.c (lto_output_node, lto_output_varpool_node,
	input_overwrite_node, input_varpool_node): Stream unique_name.
	* cgraphclones.c (cgraph_create_virtual_clone,
	cgraph_function_versioning): Set unique_name.
	* ipa.c (function_and_variable_visibility): Set unique_name.

From-SVN: r198710
parent 8b28cf47
2013-05-08 Jan Hubicka <jh@suse.cz>
PR lto/54095
* cgraph.c (cgraph_make_node_local_1): Se unique_name.
* cgraph.h (symtab_node_base): Add unique_name.
* lto-cgraph.c (lto_output_node, lto_output_varpool_node,
input_overwrite_node, input_varpool_node): Stream unique_name.
* cgraphclones.c (cgraph_create_virtual_clone,
cgraph_function_versioning): Set unique_name.
* ipa.c (function_and_variable_visibility): Set unique_name.
2013-05-08 Bill Schmidt <wschmidt@linux.vnet.ibm.com> 2013-05-08 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
* gimple-ssa-strength-reduction.c (find_phi_def): Revert former "fix." * gimple-ssa-strength-reduction.c (find_phi_def): Revert former "fix."
......
...@@ -1798,6 +1798,8 @@ cgraph_make_node_local_1 (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) ...@@ -1798,6 +1798,8 @@ cgraph_make_node_local_1 (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
node->symbol.externally_visible = false; node->symbol.externally_visible = false;
node->local.local = true; node->local.local = true;
node->symbol.unique_name = (node->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY
|| node->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY_EXP);
node->symbol.resolution = LDPR_PREVAILING_DEF_IRONLY; node->symbol.resolution = LDPR_PREVAILING_DEF_IRONLY;
gcc_assert (cgraph_function_body_availability (node) == AVAIL_LOCAL); gcc_assert (cgraph_function_body_availability (node) == AVAIL_LOCAL);
} }
......
...@@ -62,6 +62,8 @@ struct GTY(()) symtab_node_base ...@@ -62,6 +62,8 @@ struct GTY(()) symtab_node_base
/* Needed variables might become dead by optimization. This flag /* Needed variables might become dead by optimization. This flag
forces the variable to be output even if it appears dead otherwise. */ forces the variable to be output even if it appears dead otherwise. */
unsigned force_output : 1; unsigned force_output : 1;
/* True when the name is known to be unique and thus it does not need mangling. */
unsigned unique_name : 1;
/* Ordering of all symtab entries. */ /* Ordering of all symtab entries. */
int order; int order;
......
...@@ -324,6 +324,14 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node, ...@@ -324,6 +324,14 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node,
DECL_STATIC_DESTRUCTOR (new_node->symbol.decl) = 0; DECL_STATIC_DESTRUCTOR (new_node->symbol.decl) = 0;
new_node->clone.tree_map = tree_map; new_node->clone.tree_map = tree_map;
new_node->clone.args_to_skip = args_to_skip; new_node->clone.args_to_skip = args_to_skip;
/* Clones of global symbols or symbols with unique names are unique. */
if ((TREE_PUBLIC (old_decl)
&& !DECL_EXTERNAL (old_decl)
&& !DECL_WEAK (old_decl)
&& !DECL_COMDAT (old_decl))
|| in_lto_p)
new_node->symbol.unique_name = true;
FOR_EACH_VEC_SAFE_ELT (tree_map, i, map) FOR_EACH_VEC_SAFE_ELT (tree_map, i, map)
{ {
tree var = map->new_tree; tree var = map->new_tree;
...@@ -739,6 +747,13 @@ cgraph_function_versioning (struct cgraph_node *old_version_node, ...@@ -739,6 +747,13 @@ cgraph_function_versioning (struct cgraph_node *old_version_node,
new_version_node->symbol.externally_visible = 0; new_version_node->symbol.externally_visible = 0;
new_version_node->local.local = 1; new_version_node->local.local = 1;
new_version_node->lowered = true; new_version_node->lowered = true;
/* Clones of global symbols or symbols with unique names are unique. */
if ((TREE_PUBLIC (old_decl)
&& !DECL_EXTERNAL (old_decl)
&& !DECL_WEAK (old_decl)
&& !DECL_COMDAT (old_decl))
|| in_lto_p)
new_version_node->symbol.unique_name = true;
/* Update the call_expr on the edges to call the new version node. */ /* Update the call_expr on the edges to call the new version node. */
update_call_expr (new_version_node); update_call_expr (new_version_node);
......
...@@ -786,6 +786,9 @@ function_and_variable_visibility (bool whole_program) ...@@ -786,6 +786,9 @@ function_and_variable_visibility (bool whole_program)
{ {
gcc_assert (whole_program || in_lto_p gcc_assert (whole_program || in_lto_p
|| !TREE_PUBLIC (node->symbol.decl)); || !TREE_PUBLIC (node->symbol.decl));
node->symbol.unique_name = ((node->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY
|| node->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
&& TREE_PUBLIC (node->symbol.decl));
symtab_make_decl_local (node->symbol.decl); symtab_make_decl_local (node->symbol.decl);
node->symbol.resolution = LDPR_PREVAILING_DEF_IRONLY; node->symbol.resolution = LDPR_PREVAILING_DEF_IRONLY;
if (node->symbol.same_comdat_group) if (node->symbol.same_comdat_group)
...@@ -861,6 +864,9 @@ function_and_variable_visibility (bool whole_program) ...@@ -861,6 +864,9 @@ function_and_variable_visibility (bool whole_program)
{ {
gcc_assert (in_lto_p || whole_program || !TREE_PUBLIC (vnode->symbol.decl)); gcc_assert (in_lto_p || whole_program || !TREE_PUBLIC (vnode->symbol.decl));
symtab_make_decl_local (vnode->symbol.decl); symtab_make_decl_local (vnode->symbol.decl);
vnode->symbol.unique_name = ((vnode->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY
|| vnode->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
&& TREE_PUBLIC (vnode->symbol.decl));
if (vnode->symbol.same_comdat_group) if (vnode->symbol.same_comdat_group)
symtab_dissolve_same_comdat_group_list ((symtab_node) vnode); symtab_dissolve_same_comdat_group_list ((symtab_node) vnode);
vnode->symbol.resolution = LDPR_PREVAILING_DEF_IRONLY; vnode->symbol.resolution = LDPR_PREVAILING_DEF_IRONLY;
......
...@@ -468,6 +468,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, ...@@ -468,6 +468,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
bp_pack_value (&bp, node->local.can_change_signature, 1); bp_pack_value (&bp, node->local.can_change_signature, 1);
bp_pack_value (&bp, node->local.redefined_extern_inline, 1); bp_pack_value (&bp, node->local.redefined_extern_inline, 1);
bp_pack_value (&bp, node->symbol.force_output, 1); bp_pack_value (&bp, node->symbol.force_output, 1);
bp_pack_value (&bp, node->symbol.unique_name, 1);
bp_pack_value (&bp, node->symbol.address_taken, 1); bp_pack_value (&bp, node->symbol.address_taken, 1);
bp_pack_value (&bp, node->abstract_and_needed, 1); bp_pack_value (&bp, node->abstract_and_needed, 1);
bp_pack_value (&bp, tag == LTO_symtab_analyzed_node bp_pack_value (&bp, tag == LTO_symtab_analyzed_node
...@@ -533,6 +534,7 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node ...@@ -533,6 +534,7 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node
bp = bitpack_create (ob->main_stream); bp = bitpack_create (ob->main_stream);
bp_pack_value (&bp, node->symbol.externally_visible, 1); bp_pack_value (&bp, node->symbol.externally_visible, 1);
bp_pack_value (&bp, node->symbol.force_output, 1); bp_pack_value (&bp, node->symbol.force_output, 1);
bp_pack_value (&bp, node->symbol.unique_name, 1);
bp_pack_value (&bp, node->finalized, 1); bp_pack_value (&bp, node->finalized, 1);
bp_pack_value (&bp, node->alias, 1); bp_pack_value (&bp, node->alias, 1);
bp_pack_value (&bp, node->alias_of != NULL, 1); bp_pack_value (&bp, node->alias_of != NULL, 1);
...@@ -886,6 +888,7 @@ input_overwrite_node (struct lto_file_decl_data *file_data, ...@@ -886,6 +888,7 @@ input_overwrite_node (struct lto_file_decl_data *file_data,
node->local.can_change_signature = bp_unpack_value (bp, 1); node->local.can_change_signature = bp_unpack_value (bp, 1);
node->local.redefined_extern_inline = bp_unpack_value (bp, 1); node->local.redefined_extern_inline = bp_unpack_value (bp, 1);
node->symbol.force_output = bp_unpack_value (bp, 1); node->symbol.force_output = bp_unpack_value (bp, 1);
node->symbol.unique_name = bp_unpack_value (bp, 1);
node->symbol.address_taken = bp_unpack_value (bp, 1); node->symbol.address_taken = bp_unpack_value (bp, 1);
node->abstract_and_needed = bp_unpack_value (bp, 1); node->abstract_and_needed = bp_unpack_value (bp, 1);
node->symbol.used_from_other_partition = bp_unpack_value (bp, 1); node->symbol.used_from_other_partition = bp_unpack_value (bp, 1);
...@@ -1040,6 +1043,7 @@ input_varpool_node (struct lto_file_decl_data *file_data, ...@@ -1040,6 +1043,7 @@ input_varpool_node (struct lto_file_decl_data *file_data,
bp = streamer_read_bitpack (ib); bp = streamer_read_bitpack (ib);
node->symbol.externally_visible = bp_unpack_value (&bp, 1); node->symbol.externally_visible = bp_unpack_value (&bp, 1);
node->symbol.force_output = bp_unpack_value (&bp, 1); node->symbol.force_output = bp_unpack_value (&bp, 1);
node->symbol.unique_name = bp_unpack_value (&bp, 1);
node->finalized = bp_unpack_value (&bp, 1); node->finalized = bp_unpack_value (&bp, 1);
node->alias = bp_unpack_value (&bp, 1); node->alias = bp_unpack_value (&bp, 1);
non_null_aliasof = bp_unpack_value (&bp, 1); non_null_aliasof = bp_unpack_value (&bp, 1);
......
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