summaryrefslogtreecommitdiff
path: root/gcc/lto-symtab.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/lto-symtab.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/lto-symtab.c')
-rw-r--r--gcc/lto-symtab.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/gcc/lto-symtab.c b/gcc/lto-symtab.c
index bdfbd7d67a2..1d90ab113f6 100644
--- a/gcc/lto-symtab.c
+++ b/gcc/lto-symtab.c
@@ -51,6 +51,8 @@ struct GTY(()) lto_symtab_entry_def
/* LTO file-data and symbol resolution for this decl. */
struct lto_file_decl_data * GTY((skip (""))) file_data;
enum ld_plugin_symbol_resolution resolution;
+ /* True when resolution was guessed and not read from the file. */
+ bool guessed;
/* Pointer to the next entry with the same key. Before decl merging
this links all symbols from the different TUs. After decl merging
this links merged but incompatible decls, thus all prevailing ones
@@ -513,12 +515,14 @@ lto_symtab_resolve_symbols (void **slot)
if (!lto_symtab_resolve_can_prevail_p (e))
{
e->resolution = LDPR_RESOLVED_IR;
+ e->guessed = true;
continue;
}
/* Set a default resolution - the final prevailing one will get
adjusted later. */
e->resolution = LDPR_PREEMPTED_IR;
+ e->guessed = true;
if (!lto_symtab_resolve_replaceable_p (e))
{
if (prevailing)
@@ -572,6 +576,7 @@ found:
resolution file. These variables still need manual
externally_visible attribute. */
prevailing->resolution = LDPR_PREVAILING_DEF_IRONLY;
+ prevailing->guessed = true;
}
/* Merge all decls in the symbol table chain to the prevailing decl and
@@ -740,27 +745,21 @@ lto_symtab_merge_decls_1 (void **slot, void *data ATTRIBUTE_UNUSED)
&& TREE_CODE (prevailing->decl) != VAR_DECL)
prevailing->next = NULL;
- /* Set used_from_object_file flags. */
- if (prevailing->resolution == LDPR_PREVAILING_DEF
- || prevailing->resolution == LDPR_PREEMPTED_REG
- || prevailing->resolution == LDPR_RESOLVED_EXEC
- || prevailing->resolution == LDPR_RESOLVED_DYN)
- {
- if (TREE_CODE (prevailing->decl) == FUNCTION_DECL)
- {
- if (prevailing->node->same_body_alias)
- prevailing->node->same_body->local.used_from_object_file = true;
- else
- prevailing->node->local.used_from_object_file = true;
- }
- else
- {
- if (prevailing->vnode->alias)
- prevailing->vnode->extra_name->used_from_object_file = true;
- else
- prevailing->vnode->used_from_object_file = true;
- }
- }
+ /* Store resolution decision into the callgraph.
+ In LTRANS don't overwrite information we stored into callgraph at
+ WPA stage.
+
+ Do not bother to store guessed decisions. Generic code knows how
+ to handle UNKNOWN relocation well.
+
+ The problem with storing guessed decision is whether to use
+ PREVAILING_DEF or PREVAILING_DEF_IRONLY. First one would disable
+ some whole program optimizations, while ther second would imply
+ to many whole program assumptions. */
+ if (prevailing->node && !flag_ltrans && !prevailing->guessed)
+ prevailing->node->resolution = prevailing->resolution;
+ else if (prevailing->vnode && !flag_ltrans && !prevailing->guessed)
+ prevailing->vnode->resolution = prevailing->resolution;
return 1;
}