summaryrefslogtreecommitdiff
path: root/gcc/varpool.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-24 21:47:59 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-24 21:47:59 +0000
commit9ced88d06001d374cf02699ad98932d928d3d564 (patch)
tree83ac2cd6e9618944ed45f4905c495d5b42344809 /gcc/varpool.c
parent585d208eac2e8e45cd016bcde67ef3b35658f0a5 (diff)
downloadgcc-9ced88d06001d374cf02699ad98932d928d3d564.tar.gz
* lto-symtab.c (lto_symtab_entry_def): Add guessed field.
(lto_symtab_resolve_symbols): Set it. (lto_symtab_merge_decls_1): Do not compute used_from_object_file; store resolution field in cgraph/varpool. * cgraph.c (cgraph_same_body_alias, cgraph_add_thunk): Return node. (cgraph_get_node_or_alias, cgraph_get_node_or_alias): Constify. (cgraph_dump_node): Drop used_from_object_file. (cgraph_clone_node, cgraph_create_virtual_clone): Likewise. (cgraph_function_body_availability): Use decl_replaceable_p. (cgraph_make_node_local): Set resolution to LDPR_PREVAILING_DEF_IRONLY. (cgraph_can_remove_if_no_direct_calls_and_refs): Use cgraph_used_from_object_file_p. (cgraph_will_be_removed_from_program_if_no_direct_calls): Use cgraph_used_from_object_file_p. (resolution_used_from_other_file_p): New functoin. (cgraph_used_from_object_file_p): New predicate. * cgraph.h: Include plugin-api.h (struct cgraph_local_info): Remove used_from_object_file. (struct cgraph_node): Add resolution field. (struct varpool_node): Likewise; remove used_from_object_file; reove const_value_known. (cgraph_get_node, cgraph_get_node_or_alias, cgraph_node, cgraph_same_body_alias, cgraph_add_thunk): Update prototypes. (resolution_used_from_other_file_p, cgraph_used_from_object_file_p, varpool_used_from_object_file_p): Declare. (varpool_get_node, varpool_extra_name_alias): Update prototype. * tree.h (DECL_REPLACEABLE_P): Remove. (decl_replaceable_p, decl_binds_to_current_def_p): Declare. * final.c (rest_of_clean_state): Use decl_binds_to_current_def_p. * lto-cgraph.c (lto_output_node, lto_output_varpool_node, input_overwrite_node, input_node, input_varpool_node): Stream resolution. * expr.c (expand_expr_real_1): Use const_value_known_p * ipa.c (ipa_discover_readonly_nonaddressable_var): Do not set const_value_known. (cgraph_externally_visible_p): Use cgraph_used_from_object_file_p. (function_and_variable_visibility): Set resolution for local vars and functions. use varpool_used_from_object_file_p. * varasm.c (resolution_to_local_definition_p, resolution_local_p): New static functions. (default_binds_local_p_1): Use resolutoin info. (decl_binds_to_current_def_p, decl_replaceable_p): New functions. * varpool.c (varpool_get_node): Constify. (const_value_known_p): Do not use vnode->const_value_known; use decl_replaceable_p. (varpool_finalize_decl): Do not set const_value_known. (cgraph_variable_initializer_availability): Use decl_replaceable_p (varpool_extra_name_alias): Return new node. (varpool_used_from_object_file_p): New function. * decl.c (finish_function): Use decl_replaceable_p * method.c (make_alias_for_thunk): Update call of cgraph_same_body_alias. * lto.c (lto_promote_cross_file_statics): Use const_value_known_p. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164610 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/varpool.c')
-rw-r--r--gcc/varpool.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/gcc/varpool.c b/gcc/varpool.c
index 673905d5a76..ff3631b3478 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -107,7 +107,7 @@ eq_varpool_node (const void *p1, const void *p2)
/* Return varpool node assigned to DECL without creating new one. */
struct varpool_node *
-varpool_get_node (tree decl)
+varpool_get_node (const_tree decl)
{
struct varpool_node key, **slot;
@@ -116,7 +116,7 @@ varpool_get_node (tree decl)
if (!varpool_hash)
return NULL;
- key.decl = decl;
+ key.decl = CONST_CAST2 (tree, const_tree, decl);
slot = (struct varpool_node **)
htab_find_slot (varpool_hash, &key, NO_INSERT);
if (!slot)
@@ -365,8 +365,6 @@ decide_is_variable_needed (struct varpool_node *node, tree decl)
bool
const_value_known_p (tree decl)
{
- struct varpool_node *vnode;
-
if (TREE_CODE (decl) != VAR_DECL
&&TREE_CODE (decl) != CONST_DECL)
return false;
@@ -386,21 +384,12 @@ const_value_known_p (tree decl)
gcc_assert (TREE_STATIC (decl) || DECL_EXTERNAL (decl));
- /* In WHOPR mode we can put variable into one partition
- and make it external in the other partition. In this
- case we still know the value, but it can't be determined
- from DECL flags. For this reason we keep const_value_known
- flag in varpool nodes. */
- if ((vnode = varpool_get_node (decl))
- && vnode->const_value_known)
- return true;
-
/* Variables declared 'const' without an initializer
have zero as the initializer if they may not be
overridden at link or run time. */
if (!DECL_INITIAL (decl)
&& (DECL_EXTERNAL (decl)
- || DECL_REPLACEABLE_P (decl)))
+ || decl_replaceable_p (decl)))
return false;
/* Variables declared `const' with an initializer are considered
@@ -444,7 +433,6 @@ varpool_finalize_decl (tree decl)
there. */
else if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
varpool_mark_needed_node (node);
- node->const_value_known |= const_value_known_p (node->decl);
if (cgraph_global_info_ready)
varpool_assemble_pending_decls ();
}
@@ -462,7 +450,7 @@ cgraph_variable_initializer_availability (struct varpool_node *node)
/* If the variable can be overwritten, return OVERWRITABLE. Takes
care of at least two notable extensions - the COMDAT variables
used to share template instantiations in C++. */
- if (!(*targetm.binds_local_p) (node->decl) && !DECL_COMDAT (node->decl))
+ if (!decl_replaceable_p (node->decl))
return AVAIL_OVERWRITABLE;
return AVAIL_AVAILABLE;
}
@@ -674,7 +662,7 @@ add_new_static_var (tree type)
/* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
Extra name aliases are output whenever DECL is output. */
-bool
+struct varpool_node *
varpool_extra_name_alias (tree alias, tree decl)
{
struct varpool_node key, *alias_node, *decl_node, **slot;
@@ -695,7 +683,7 @@ varpool_extra_name_alias (tree alias, tree decl)
/* If the varpool_node has been already created, fail. */
if (*slot)
- return false;
+ return NULL;
alias_node = ggc_alloc_cleared_varpool_node ();
alias_node->decl = alias;
@@ -707,7 +695,26 @@ varpool_extra_name_alias (tree alias, tree decl)
decl_node->extra_name->prev = alias_node;
decl_node->extra_name = alias_node;
*slot = alias_node;
- return true;
+ return alias_node;
+}
+
+/* Return true when NODE is known to be used from other (non-LTO) object file.
+ Known only when doing LTO via linker plugin. */
+
+bool
+varpool_used_from_object_file_p (struct varpool_node *node)
+{
+ struct varpool_node *alias;
+
+ if (!TREE_PUBLIC (node->decl))
+ return false;
+ if (resolution_used_from_other_file_p (node->resolution))
+ return true;
+ for (alias = node->extra_name; alias; alias = alias->next)
+ if (TREE_PUBLIC (alias->decl)
+ && resolution_used_from_other_file_p (alias->resolution))
+ return true;
+ return false;
}
#include "gt-varpool.h"