aboutsummaryrefslogtreecommitdiff
path: root/gcc/varpool.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2010-11-16 19:15:17 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2010-11-16 18:15:17 +0000
commitdf7705b18e1ca275f0ded892bd5fb6bd542eb988 (patch)
treeb9cf407f17bdb390a410566498c603ef34073ef6 /gcc/varpool.c
parent3e794bfe4393d5398c21658837c7437f1a1cbc5c (diff)
downloadgcc-df7705b18e1ca275f0ded892bd5fb6bd542eb988.zip
gcc-df7705b18e1ca275f0ded892bd5fb6bd542eb988.tar.gz
gcc-df7705b18e1ca275f0ded892bd5fb6bd542eb988.tar.bz2
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
Diffstat (limited to 'gcc/varpool.c')
-rw-r--r--gcc/varpool.c38
1 files changed, 11 insertions, 27 deletions
diff --git a/gcc/varpool.c b/gcc/varpool.c
index 2a96d79..8822660 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -331,31 +331,24 @@ varpool_reset_queue (void)
bool
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 ((node->externally_visible && !DECL_COMDAT (decl))
- || node->force_output)
+ if (node->force_output)
return true;
+ gcc_assert (!DECL_EXTERNAL (decl));
+
/* Externally visible variables must be output. The exception is
COMDAT variables that must be output only when they are needed. */
if (TREE_PUBLIC (decl)
- && !flag_whole_program
- && !flag_lto
&& !DECL_COMDAT (decl)
&& !DECL_EXTERNAL (decl))
return true;
/* When not reordering top level variables, we have to assume that
we are going to keep everything. */
- if (flag_toplevel_reorder)
- return false;
-
- /* We want to emit COMDAT variables only when absolutely necessary. */
- if (DECL_COMDAT (decl))
- return false;
- return true;
+ if (!flag_toplevel_reorder)
+ return true;
+ return false;
}
/* Return if DECL is constant and its initial value is known (so we can do
@@ -427,11 +420,6 @@ varpool_finalize_decl (tree decl)
if (decide_is_variable_needed (node, decl))
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)
varpool_assemble_pending_decls ();
}
@@ -557,18 +545,14 @@ varpool_remove_unreferenced_decls (void)
while (node)
{
- tree decl = node->decl;
next = node->next_needed;
node->needed = 0;
- if (node->finalized
- && (decide_is_variable_needed (node, decl)
- /* ??? Cgraph does not yet rule the world with an iron hand,
- and does not control the emission of debug information.
- After a variable has its DECL_RTL set, we must assume that
- it may be referenced by the debug information, and we can
- no longer elide it. */
- || DECL_RTL_SET_P (decl)))
+ if (node->analyzed
+ && (!varpool_can_remove_if_no_refs (node)
+ /* We just expanded all function bodies. See if any of
+ them needed the variable. */
+ || DECL_RTL_SET_P (node->decl)))
varpool_mark_needed_node (node);
node = next;