Commit df7705b1 by Jan Hubicka Committed by Jan Hubicka

cgraph.h (+varpool_can_remove_if_no_refs): Move here from ......


	* cgraph.h (+varpool_can_remove_if_no_refs): Move here from ...;
	when !flag_toplevel_reorder do not remove unless variable is
	COMDAT or ARTIFICIAL.
	* ipa.c (varpool_can_remove_if_no_refs): ... here.
	(cgraph_remove_unreachable_nodes): Only analyzed nodes needs to stay.
	* cgraphunit.c (cgraph_analyze_functions): Dump varpool, too.
	* varpool.c (decide_is_variable_needed): Do not handle visibility issues.
	(varpool_finalize_decl): Likewise.
	(varpool_remove_unreferenced_decls): Use varpool_mark_needed_node; update
	outdated comment on DECL_RTL_SET_P check.

From-SVN: r166812
parent 3e794bfe
2010-11-16 Jan Hubicka <jh@suse.cz>
* cgraph.h (+varpool_can_remove_if_no_refs): Move here from ...;
when !flag_toplevel_reorder do not remove unless variable is
COMDAT or ARTIFICIAL.
* ipa.c (varpool_can_remove_if_no_refs): ... here.
(cgraph_remove_unreachable_nodes): Only analyzed nodes needs to stay.
* cgraphunit.c (cgraph_analyze_functions): Dump varpool, too.
* varpool.c (decide_is_variable_needed): Do not handle visibility issues.
(varpool_finalize_decl): Likewise.
(varpool_remove_unreferenced_decls): Use varpool_mark_needed_node; update
outdated comment on DECL_RTL_SET_P check.
2010-11-16 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2010-11-16 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* config/sol2.h (NM_FLAGS): Define. * config/sol2.h (NM_FLAGS): Define.
...@@ -928,6 +928,18 @@ cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node) ...@@ -928,6 +928,18 @@ cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
return !node->address_taken && cgraph_can_remove_if_no_direct_calls_and_refs_p (node); return !node->address_taken && cgraph_can_remove_if_no_direct_calls_and_refs_p (node);
} }
/* Return true when function NODE can be removed from callgraph
if all direct calls are eliminated. */
static inline bool
varpool_can_remove_if_no_refs (struct varpool_node *node)
{
return (!node->force_output && !node->used_from_other_partition
&& (flag_toplevel_reorder || DECL_COMDAT (node->decl)
|| DECL_ARTIFICIAL (node->decl))
&& (DECL_COMDAT (node->decl) || !node->externally_visible));
}
/* Return true when all references to VNODE must be visible in ipa_ref_list. /* Return true when all references to VNODE must be visible in ipa_ref_list.
i.e. if the variable is not externally visible or not used in some magic i.e. if the variable is not externally visible or not used in some magic
way (asm statement or such). way (asm statement or such).
......
...@@ -943,6 +943,7 @@ cgraph_analyze_functions (void) ...@@ -943,6 +943,7 @@ cgraph_analyze_functions (void)
fprintf (cgraph_dump_file, " %s", cgraph_node_name (node)); fprintf (cgraph_dump_file, " %s", cgraph_node_name (node));
fprintf (cgraph_dump_file, "\n\nInitial "); fprintf (cgraph_dump_file, "\n\nInitial ");
dump_cgraph (cgraph_dump_file); dump_cgraph (cgraph_dump_file);
dump_varpool (cgraph_dump_file);
} }
if (cgraph_dump_file) if (cgraph_dump_file)
...@@ -972,6 +973,7 @@ cgraph_analyze_functions (void) ...@@ -972,6 +973,7 @@ cgraph_analyze_functions (void)
{ {
fprintf (cgraph_dump_file, "\n\nReclaimed "); fprintf (cgraph_dump_file, "\n\nReclaimed ");
dump_cgraph (cgraph_dump_file); dump_cgraph (cgraph_dump_file);
dump_varpool (cgraph_dump_file);
} }
bitmap_obstack_release (NULL); bitmap_obstack_release (NULL);
first_analyzed = cgraph_nodes; first_analyzed = cgraph_nodes;
...@@ -1816,6 +1818,7 @@ cgraph_optimize (void) ...@@ -1816,6 +1818,7 @@ cgraph_optimize (void)
{ {
fprintf (cgraph_dump_file, "\nFinal "); fprintf (cgraph_dump_file, "\nFinal ");
dump_cgraph (cgraph_dump_file); dump_cgraph (cgraph_dump_file);
dump_varpool (cgraph_dump_file);
} }
#ifdef ENABLE_CHECKING #ifdef ENABLE_CHECKING
verify_cgraph (); verify_cgraph ();
......
...@@ -188,16 +188,6 @@ process_references (struct ipa_ref_list *list, ...@@ -188,16 +188,6 @@ process_references (struct ipa_ref_list *list,
} }
} }
/* Return true when function NODE can be removed from callgraph
if all direct calls are eliminated. */
static inline bool
varpool_can_remove_if_no_refs (struct varpool_node *node)
{
return (!node->force_output && !node->used_from_other_partition
&& (DECL_COMDAT (node->decl) || !node->externally_visible));
}
/* Return true when function can be marked local. */ /* Return true when function can be marked local. */
static bool static bool
...@@ -269,7 +259,8 @@ cgraph_remove_unreachable_nodes (bool before_inlining_p, FILE *file) ...@@ -269,7 +259,8 @@ cgraph_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
{ {
vnode->next_needed = NULL; vnode->next_needed = NULL;
vnode->prev_needed = NULL; vnode->prev_needed = NULL;
if (!varpool_can_remove_if_no_refs (vnode)) if (vnode->analyzed
&& !varpool_can_remove_if_no_refs (vnode))
{ {
vnode->needed = false; vnode->needed = false;
varpool_mark_needed_node (vnode); varpool_mark_needed_node (vnode);
......
...@@ -331,31 +331,24 @@ varpool_reset_queue (void) ...@@ -331,31 +331,24 @@ varpool_reset_queue (void)
bool bool
decide_is_variable_needed (struct varpool_node *node, tree decl) decide_is_variable_needed (struct varpool_node *node, tree decl)
{ {
if (node->used_from_other_partition)
return true;
/* If the user told us it is used, then it must be so. */ /* If the user told us it is used, then it must be so. */
if ((node->externally_visible && !DECL_COMDAT (decl)) if (node->force_output)
|| node->force_output)
return true; return true;
gcc_assert (!DECL_EXTERNAL (decl));
/* Externally visible variables must be output. The exception is /* Externally visible variables must be output. The exception is
COMDAT variables that must be output only when they are needed. */ COMDAT variables that must be output only when they are needed. */
if (TREE_PUBLIC (decl) if (TREE_PUBLIC (decl)
&& !flag_whole_program
&& !flag_lto
&& !DECL_COMDAT (decl) && !DECL_COMDAT (decl)
&& !DECL_EXTERNAL (decl)) && !DECL_EXTERNAL (decl))
return true; return true;
/* When not reordering top level variables, we have to assume that /* When not reordering top level variables, we have to assume that
we are going to keep everything. */ we are going to keep everything. */
if (flag_toplevel_reorder) if (!flag_toplevel_reorder)
return false; return true;
return false;
/* We want to emit COMDAT variables only when absolutely necessary. */
if (DECL_COMDAT (decl))
return false;
return true;
} }
/* Return if DECL is constant and its initial value is known (so we can do /* Return if DECL is constant and its initial value is known (so we can do
...@@ -427,11 +420,6 @@ varpool_finalize_decl (tree decl) ...@@ -427,11 +420,6 @@ varpool_finalize_decl (tree decl)
if (decide_is_variable_needed (node, decl)) if (decide_is_variable_needed (node, decl))
varpool_mark_needed_node (node); varpool_mark_needed_node (node);
/* Since we reclaim unreachable nodes at the end of every language
level unit, we need to be conservative about possible entry points
there. */
else if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
varpool_mark_needed_node (node);
if (cgraph_global_info_ready) if (cgraph_global_info_ready)
varpool_assemble_pending_decls (); varpool_assemble_pending_decls ();
} }
...@@ -557,18 +545,14 @@ varpool_remove_unreferenced_decls (void) ...@@ -557,18 +545,14 @@ varpool_remove_unreferenced_decls (void)
while (node) while (node)
{ {
tree decl = node->decl;
next = node->next_needed; next = node->next_needed;
node->needed = 0; node->needed = 0;
if (node->finalized if (node->analyzed
&& (decide_is_variable_needed (node, decl) && (!varpool_can_remove_if_no_refs (node)
/* ??? Cgraph does not yet rule the world with an iron hand, /* We just expanded all function bodies. See if any of
and does not control the emission of debug information. them needed the variable. */
After a variable has its DECL_RTL set, we must assume that || DECL_RTL_SET_P (node->decl)))
it may be referenced by the debug information, and we can
no longer elide it. */
|| DECL_RTL_SET_P (decl)))
varpool_mark_needed_node (node); varpool_mark_needed_node (node);
node = next; node = next;
......
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