diff options
author | Jan Hubicka <jh@suse.cz> | 2010-09-24 23:47:59 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2010-09-24 21:47:59 +0000 |
commit | 051f8cc6c71cf29bda39effeb4bc6b0ff2e36d65 (patch) | |
tree | 83ac2cd6e9618944ed45f4905c495d5b42344809 /gcc/cgraph.c | |
parent | 5c255b57b25e4847b8e556c4b6450e6f559329ff (diff) | |
download | gcc-051f8cc6c71cf29bda39effeb4bc6b0ff2e36d65.zip gcc-051f8cc6c71cf29bda39effeb4bc6b0ff2e36d65.tar.gz gcc-051f8cc6c71cf29bda39effeb4bc6b0ff2e36d65.tar.bz2 |
lto-symtab.c (lto_symtab_entry_def): Add guessed field.
* 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.
From-SVN: r164610
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r-- | gcc/cgraph.c | 67 |
1 files changed, 51 insertions, 16 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 470fb5a..7293b6d 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -555,24 +555,29 @@ cgraph_same_body_alias_1 (tree alias, tree decl) return alias_node; } -/* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful. +/* Attempt to mark ALIAS as an alias to DECL. Return alias node if successful + and NULL otherwise. Same body aliases are output whenever the body of DECL is output, and cgraph_node (ALIAS) transparently returns cgraph_node (DECL). */ -bool +struct cgraph_node * cgraph_same_body_alias (tree alias, tree decl) { #ifndef ASM_OUTPUT_DEF /* If aliases aren't supported by the assembler, fail. */ - return false; + return NULL; #endif /*gcc_assert (!assembler_name_hash);*/ - return cgraph_same_body_alias_1 (alias, decl) != NULL; + return cgraph_same_body_alias_1 (alias, decl); } -void +/* Add thunk alias into callgraph. The alias declaration is ALIAS and it + alises DECL with an adjustments made into the first parameter. + See comments in thunk_adjust for detail on the parameters. */ + +struct cgraph_node * cgraph_add_thunk (tree alias, tree decl, bool this_adjusting, HOST_WIDE_INT fixed_offset, HOST_WIDE_INT virtual_value, tree virtual_offset, @@ -599,13 +604,14 @@ cgraph_add_thunk (tree alias, tree decl, bool this_adjusting, node->thunk.virtual_offset_p = virtual_offset != NULL; node->thunk.alias = real_alias; node->thunk.thunk_p = true; + return node; } /* Returns the cgraph node assigned to DECL or NULL if no cgraph node is assigned. */ struct cgraph_node * -cgraph_get_node_or_alias (tree decl) +cgraph_get_node_or_alias (const_tree decl) { struct cgraph_node key, *node = NULL, **slot; @@ -614,7 +620,7 @@ cgraph_get_node_or_alias (tree decl) if (!cgraph_hash) return NULL; - key.decl = decl; + key.decl = CONST_CAST2 (tree, const_tree, decl); slot = (struct cgraph_node **) htab_find_slot (cgraph_hash, &key, NO_INSERT); @@ -628,7 +634,7 @@ cgraph_get_node_or_alias (tree decl) is assigned. */ struct cgraph_node * -cgraph_get_node (tree decl) +cgraph_get_node (const_tree decl) { struct cgraph_node key, *node = NULL, **slot; @@ -637,7 +643,7 @@ cgraph_get_node (tree decl) if (!cgraph_hash) return NULL; - key.decl = decl; + key.decl = CONST_CAST2 (tree, const_tree, decl); slot = (struct cgraph_node **) htab_find_slot (cgraph_hash, &key, NO_INSERT); @@ -1849,8 +1855,6 @@ dump_cgraph_node (FILE *f, struct cgraph_node *node) fprintf (f, " local"); if (node->local.externally_visible) fprintf (f, " externally_visible"); - if (node->local.used_from_object_file) - fprintf (f, " used_from_object_file"); if (node->local.finalized) fprintf (f, " finalized"); if (node->local.disregard_inline_limits) @@ -2124,7 +2128,6 @@ cgraph_clone_node (struct cgraph_node *n, tree decl, gcov_type count, int freq, new_node->analyzed = n->analyzed; new_node->local = n->local; new_node->local.externally_visible = false; - new_node->local.used_from_object_file = false; new_node->local.local = true; new_node->local.vtable_method = false; new_node->global = n->global; @@ -2318,7 +2321,6 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node, else new_node->clone.combined_args_to_skip = args_to_skip; new_node->local.externally_visible = 0; - new_node->local.used_from_object_file = 0; new_node->local.local = 1; new_node->lowered = true; new_node->reachable = true; @@ -2369,7 +2371,7 @@ cgraph_function_body_availability (struct cgraph_node *node) AVAIL_AVAILABLE here? That would be good reason to preserve this bit. */ - else if (DECL_REPLACEABLE_P (node->decl) && !DECL_EXTERNAL (node->decl)) + else if (decl_replaceable_p (node->decl) && !DECL_EXTERNAL (node->decl)) avail = AVAIL_OVERWRITABLE; else avail = AVAIL_AVAILABLE; @@ -2556,6 +2558,7 @@ cgraph_make_node_local (struct cgraph_node *node) node->local.externally_visible = false; node->local.local = true; + node->resolution = LDPR_PREVAILING_DEF_IRONLY; gcc_assert (cgraph_function_body_availability (node) == AVAIL_LOCAL); } } @@ -2720,7 +2723,8 @@ cgraph_can_remove_if_no_direct_calls_and_refs_p (struct cgraph_node *node) return false; /* Only COMDAT functions can be removed if externally visible. */ if (node->local.externally_visible - && (!DECL_COMDAT (node->decl) || node->local.used_from_object_file)) + && (!DECL_COMDAT (node->decl) + || cgraph_used_from_object_file_p (node))) return false; /* Constructors and destructors are executed by the runtime, however we can get rid of all pure constructors and destructors. */ @@ -2753,7 +2757,7 @@ cgraph_can_remove_if_no_direct_calls_and_refs_p (struct cgraph_node *node) bool cgraph_will_be_removed_from_program_if_no_direct_calls (struct cgraph_node *node) { - if (node->local.used_from_object_file) + if (cgraph_used_from_object_file_p (node)) return false; if (!in_lto_p && !flag_whole_program) return cgraph_only_called_directly_p (node); @@ -2761,4 +2765,35 @@ cgraph_will_be_removed_from_program_if_no_direct_calls (struct cgraph_node *node return cgraph_can_remove_if_no_direct_calls_p (node); } +/* Return true when RESOLUTION indicate that linker will use + the symbol from non-LTo object files. */ + +bool +resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution resolution) +{ + return (resolution == LDPR_PREVAILING_DEF + || resolution == LDPR_PREEMPTED_REG + || resolution == LDPR_RESOLVED_EXEC + || resolution == LDPR_RESOLVED_DYN); +} + +/* Return true when NODE is known to be used from other (non-LTO) object file. + Known only when doing LTO via linker plugin. */ + +bool +cgraph_used_from_object_file_p (struct cgraph_node *node) +{ + struct cgraph_node *alias; + + if (!TREE_PUBLIC (node->decl)) + return false; + if (resolution_used_from_other_file_p (node->resolution)) + return true; + for (alias = node->same_body; alias; alias = alias->next) + if (TREE_PUBLIC (alias->decl) + && resolution_used_from_other_file_p (alias->resolution)) + return true; + return false; +} + #include "gt-cgraph.h" |