Commit dcbde1f8 by Jan Hubicka Committed by Jan Hubicka

re PR ipa/65502 (pure-const should play well with clobbers.)


	PR ipa/65502
	* ipa-comdats.c (enqueue_references): Walk through thunks.
	(ipa_comdats): Likewise.
	(set_comdat_group_1): New function.

From-SVN: r221574
parent a6bfa7c7
2015-03-20 Jan Hubicka <hubicka@ucw.cz> 2015-03-20 Jan Hubicka <hubicka@ucw.cz>
PR ipa/65502
* ipa-comdats.c (enqueue_references): Walk through thunks.
(ipa_comdats): Likewise.
(set_comdat_group_1): New function.
2015-03-20 Jan Hubicka <hubicka@ucw.cz>
PR ipa/65475 PR ipa/65475
* ipa-devirt.c (add_type_duplicate): Prevail polymorphic type over * ipa-devirt.c (add_type_duplicate): Prevail polymorphic type over
non-polymorphic non-polymorphic
......
...@@ -182,6 +182,10 @@ enqueue_references (symtab_node **first, ...@@ -182,6 +182,10 @@ enqueue_references (symtab_node **first,
for (i = 0; symbol->iterate_reference (i, ref); i++) for (i = 0; symbol->iterate_reference (i, ref); i++)
{ {
symtab_node *node = ref->referred->ultimate_alias_target (); symtab_node *node = ref->referred->ultimate_alias_target ();
/* Always keep thunks in same sections as target function. */
if (is_a <cgraph_node *>(node))
node = dyn_cast <cgraph_node *> (node)->function_symbol ();
if (!node->aux && node->definition) if (!node->aux && node->definition)
{ {
node->aux = *first; node->aux = *first;
...@@ -199,6 +203,10 @@ enqueue_references (symtab_node **first, ...@@ -199,6 +203,10 @@ enqueue_references (symtab_node **first,
else else
{ {
symtab_node *node = edge->callee->ultimate_alias_target (); symtab_node *node = edge->callee->ultimate_alias_target ();
/* Always keep thunks in same sections as target function. */
if (is_a <cgraph_node *>(node))
node = dyn_cast <cgraph_node *> (node)->function_symbol ();
if (!node->aux && node->definition) if (!node->aux && node->definition)
{ {
node->aux = *first; node->aux = *first;
...@@ -209,7 +217,7 @@ enqueue_references (symtab_node **first, ...@@ -209,7 +217,7 @@ enqueue_references (symtab_node **first,
} }
/* Set comdat group of SYMBOL to GROUP. /* Set comdat group of SYMBOL to GROUP.
Callback for symtab_for_node_and_aliases. */ Callback for for_node_and_aliases. */
bool bool
set_comdat_group (symtab_node *symbol, set_comdat_group (symtab_node *symbol,
...@@ -223,6 +231,16 @@ set_comdat_group (symtab_node *symbol, ...@@ -223,6 +231,16 @@ set_comdat_group (symtab_node *symbol,
return false; return false;
} }
/* Set comdat group of SYMBOL to GROUP.
Callback for for_node_thunks_and_aliases. */
bool
set_comdat_group_1 (cgraph_node *symbol,
void *head_p)
{
return set_comdat_group (symbol, head_p);
}
/* The actual pass with the main dataflow loop. */ /* The actual pass with the main dataflow loop. */
static unsigned int static unsigned int
...@@ -263,7 +281,12 @@ ipa_comdats (void) ...@@ -263,7 +281,12 @@ ipa_comdats (void)
&& (DECL_STATIC_CONSTRUCTOR (symbol->decl) && (DECL_STATIC_CONSTRUCTOR (symbol->decl)
|| DECL_STATIC_DESTRUCTOR (symbol->decl)))) || DECL_STATIC_DESTRUCTOR (symbol->decl))))
{ {
map.put (symbol->ultimate_alias_target (), error_mark_node); symtab_node *target = symbol->ultimate_alias_target ();
/* Always keep thunks in same sections as target function. */
if (is_a <cgraph_node *>(target))
target = dyn_cast <cgraph_node *> (target)->function_symbol ();
map.put (target, error_mark_node);
/* Mark the symbol so we won't waste time visiting it for dataflow. */ /* Mark the symbol so we won't waste time visiting it for dataflow. */
symbol->aux = (symtab_node *) (void *) 1; symbol->aux = (symtab_node *) (void *) 1;
...@@ -332,10 +355,8 @@ ipa_comdats (void) ...@@ -332,10 +355,8 @@ ipa_comdats (void)
symbol->aux = NULL; symbol->aux = NULL;
if (!symbol->get_comdat_group () if (!symbol->get_comdat_group ()
&& !symbol->alias && !symbol->alias
/* Thunks to external functions do not need to be categorized. */
&& (!(fun = dyn_cast <cgraph_node *> (symbol)) && (!(fun = dyn_cast <cgraph_node *> (symbol))
|| !fun->thunk.thunk_p || !fun->thunk.thunk_p)
|| fun->function_symbol ()->definition)
&& symbol->real_symbol_p ()) && symbol->real_symbol_p ())
{ {
tree *val = map.get (symbol); tree *val = map.get (symbol);
...@@ -355,9 +376,16 @@ ipa_comdats (void) ...@@ -355,9 +376,16 @@ ipa_comdats (void)
symbol->dump (dump_file); symbol->dump (dump_file);
fprintf (dump_file, "To group: %s\n", IDENTIFIER_POINTER (group)); fprintf (dump_file, "To group: %s\n", IDENTIFIER_POINTER (group));
} }
symbol->call_for_symbol_and_aliases (set_comdat_group, if (is_a <cgraph_node *> (symbol))
*comdat_head_map.get (group), dyn_cast <cgraph_node *>(symbol)->call_for_symbol_and_aliases
true); (set_comdat_group_1,
*comdat_head_map.get (group),
true);
else
symbol->call_for_symbol_and_aliases
(set_comdat_group,
*comdat_head_map.get (group),
true);
} }
} }
return 0; return 0;
......
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