aboutsummaryrefslogtreecommitdiff
path: root/gcc/varpool.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2013-05-29 22:42:50 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2013-05-29 20:42:50 +0000
commite70670cf4db3759336199993451af2739723de87 (patch)
tree3c8fecbc03b258758055280236d0a5da8994b8cc /gcc/varpool.c
parent182802adcc315bbbc5a4e468d9a6817be6be5c08 (diff)
downloadgcc-e70670cf4db3759336199993451af2739723de87.zip
gcc-e70670cf4db3759336199993451af2739723de87.tar.gz
gcc-e70670cf4db3759336199993451af2739723de87.tar.bz2
cgraph.h (symtab_node_base): Add definition, alias and analyzed flags...
* cgraph.h (symtab_node_base): Add definition, alias and analyzed flags; reorder rest of fields in more consistent way. (varpool_node): Remove analyzed, finalized and alias. (cgraph_ndoe): Likewise. (symtab_alias_ultimate_target): New function. (cgraph_function_node): Move offline. (cgraph_reset_node): Declare. (cgraph_comdat_can_be_unshared_p): Remove. (varpool_remove_initializer): Declare. (varpool_first_defined_variable, varpool_next_defined_variable cgraph_first_defined_function, cgraph_next_defined_function): Update. (cgraph_function_with_gimple_body_p): Update. (varpool_all_refs_explicit_p): Update. (symtab_alias_target): New function. (cgraph_alias_aliased_node, varpool_alias_aliased_node): Rename to ... (cgraph_alias_target, varpool_alias_target): .. this one; simplify. (cgraph_function_or_thunk_node): Simplify using symtab_alias_ultimate_target. (varpool_variable_node): Likewise. * cgraph.c (cgraph_create_function_alias): Update. (cgraph_add_thunk): Update. (cgraph_remove_node): Update. (dump_cgraph_node): Do not dump removed flags. (cgraph_function_body_availability): Update. (cgraph_propagate_frequency): Update. (verify_cgraph_node): Check sanity of local flag. (cgraph_function_node): Move here from cgraph.h; revamp for cgraph_function_or_thunk_node. * lto-symtab.c (lto_varpool_replace_node): Update. (lto_symtab_resolve_can_prevail_p): Update. (lto_symtab_merge_cgraph_nodes): Update. * ipa-cp.c (determine_versionability, initialize_node_lattices, propagate_constants_accross_call, devirtualization_time_bonus, ipcp_propagate_stage): Update. * tree-emutls.c (create_emultls_var, ipa_lower_emutls): Update. * ipa-inline-transform.c (clone_inlined_nodes, preserve_function_body_p): Update. * ipa-reference.c (propagate): Update. (write_node_summary_p): Update. * toplev.c (wrapup_global_declaration_2): Update. * cgraphunit.c (cgraph_analyze_function): Rename to ... (analyze_function) ... this one. (cgraph_process_new_functions): Update. (cgraph_reset_node): Export. (cgraph_finalize_function): Update. (cgraph_add_new_function): Update. (process_function_and_variable_attributes): Update. (varpool_finalize_decl): Update. (symbol_finalized): Remove. (symbol_finalized_and_needed): Rename to ... (symbol_defined_and_needed): ... update. (cgraph_analyze_functions): Update. (handle_alias_pairs): Update. (mark_functions_to_output): Update. (assemble_thunk): Update. (output_in_order): Update. (output_weakrefs): Update. (finalize_compilation_unit): Update. * lto-cgraph.c (reachable_from_other_partition_p, lto_output_node, lto_output_varpool_node, compute_ltrans_boundary, input_overwrite_node, input_node, input_varpool_node): Update. * dbxout.c (dbxout_expand_expr): Update. * cgraphclones.c (cgraph_clone_node): Update. (cgraph_copy_node_for_versioning): Update. (cgraph_materialize_clone): Update. (cgraph_materialize_all_clones): Update. * ipa-pure-const.c (analyze_function, pure_const_write_summary, propagate_pure_const, propagate_nothrow): Update. * lto-streamer-out.c (lto_output, write_symbol): Update. * ipa-utils.c (ipa_reverse_postorder): Update. * ipa-inline.c (can_inline_edge_p): Update. (update_caller_keys, ipa_inline): Update. * dwarf2out.c (reference_to_unused, premark_types_used_by_global_vars_helper): Update. * tree-eh.c (tree_could_trap_p): Update. * ipa-split.c (consider_split, execute_split_functions): Update. * ipa.c (cgraph_non_local_node_p_1, cgraph_local_node_p, has_addr_references_p): Update; move ahead in file for better readability. (process_references): Simplify. (symtab_remove_unreachable_nodes): Update; cleanup way function/var bodies are removed. (cgraph_comdat_can_be_unshared_p): Make static. (cgraph_externally_visible_p): Update. (varpool_externally_visible_p): Update. (function_and_variable_visibility): Update. * trans-mem.c (get_cg_data, ipa_tm_mayenterirr_function, ipa_tm_mark_force_output_node): Update. * ipa-inline-analysis.c (dump_inline_summary, initialize_inline_failed, estimate_edge_devirt_benefit, inline_generate_summary, inline_write_summary): Update. * gimple-fold.c (can_refer_decl_in_current_unit_p): Update. * ipa-prop.c (ipa_compute_jump_functions): Update. (ipa_print_node_params, ipa_prop_read_section, ipa_update_after_lto_read, read_replacements_section): Update. * varasm.c (mark_decl_referenced): Update. (assemble_alias, dump_tm_clone_pairs): Update. * tree-inline.c (copy_bb): Update. (estimate_num_insns, optimize_inline_calls, tree_function_versioning): Update. * symtab.c (dump_symtab_base): Print new flags. (verify_symtab_base): Verify new flags. (symtab_alias_ultimate_target): New function. * tree-ssa-structalias.c (get_constraint_for_ssa_var, create_variable_info_for, associate_varinfo_to_alias, ipa_pta_execute): Update. * passes.c (ipa_write_summaries, ipa_write_optimization_summaries): Update. * i386.c (ix86_get_function_versions_dispatcher, ix86_generate_version_dispatcher_body): Update. (fold_builtin_cpu): Use varpool_add_new_variable. * varpool.c (varpool_remove_initializer): Break out from ... (varpool_remove_node): ... this one. (dump_varpool_node, varpool_node_for_asm, cgraph_variable_initializer_availability, varpool_analyze_node, varpool_assemble_decl, varpool_remove_unreferenced_decls, varpool_finalize_named_section_flags, varpool_create_variable_alias): Update * decl.c (java_mark_decl_local): Update for new symtab flags. * tree.c (cp_fix_function_decl_p): Update for new symtab flags. * decl2.c )var_finalized_p, cp_write_global_declarations): Likewise. * lto.c (has_analyzed_clone_p, lto_materialize_function): Update for new symtab flags. * lto-partition.c (get_symbol_class, lto_balanced_map): Likewise. From-SVN: r199422
Diffstat (limited to 'gcc/varpool.c')
-rw-r--r--gcc/varpool.c60
1 files changed, 34 insertions, 26 deletions
diff --git a/gcc/varpool.c b/gcc/varpool.c
index e3ad22b..1916b76 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -58,6 +58,19 @@ void
varpool_remove_node (struct varpool_node *node)
{
symtab_unregister_node ((symtab_node)node);
+
+ /* Because we remove references from external functions before final compilation,
+ we may end up removing useful constructors.
+ FIXME: We probably want to trace boundaries better. */
+ if (!const_value_known_p (node->symbol.decl))
+ varpool_remove_initializer (node);
+ ggc_free (node);
+}
+
+/* Renove node initializer when it is no longer needed. */
+void
+varpool_remove_initializer (struct varpool_node *node)
+{
if (DECL_INITIAL (node->symbol.decl)
&& !DECL_IN_CONSTANT_POOL (node->symbol.decl)
/* Keep vtables for BINFO folding. */
@@ -65,7 +78,6 @@ varpool_remove_node (struct varpool_node *node)
/* FIXME: http://gcc.gnu.org/PR55395 */
&& debug_info_level == DINFO_LEVEL_NONE)
DECL_INITIAL (node->symbol.decl) = error_mark_node;
- ggc_free (node);
}
/* Dump given cgraph node. */
@@ -80,10 +92,6 @@ dump_varpool_node (FILE *f, struct varpool_node *node)
fprintf (f, " Varpool flags:");
if (DECL_INITIAL (node->symbol.decl))
fprintf (f, " initialized");
- if (node->analyzed)
- fprintf (f, " analyzed");
- if (node->finalized)
- fprintf (f, " finalized");
if (node->output)
fprintf (f, " output");
if (TREE_READONLY (node->symbol.decl))
@@ -117,9 +125,9 @@ struct varpool_node *
varpool_node_for_asm (tree asmname)
{
if (symtab_node node = symtab_node_for_asm (asmname))
- if (varpool_node *vnode = dyn_cast <varpool_node> (node))
- return vnode;
- return NULL;
+ return dyn_cast <varpool_node> (node);
+ else
+ return NULL;
}
/* Determine if variable DECL is needed. That is, visible to something
@@ -205,12 +213,12 @@ enum availability
cgraph_variable_initializer_availability (struct varpool_node *node)
{
gcc_assert (cgraph_function_flags_ready);
- if (!node->finalized)
+ if (!node->symbol.definition)
return AVAIL_NOT_AVAILABLE;
if (!TREE_PUBLIC (node->symbol.decl))
return AVAIL_AVAILABLE;
/* If the variable can be overwritten, return OVERWRITABLE. Takes
- care of at least two notable extensions - the COMDAT variables
+ care of at least one notable extension - the COMDAT variables
used to share template instantiations in C++. */
if (!decl_replaceable_p (node->symbol.decl))
return AVAIL_OVERWRITABLE;
@@ -225,24 +233,24 @@ varpool_analyze_node (struct varpool_node *node)
/* When reading back varpool at LTO time, we re-construct the queue in order
to have "needed" list right by inserting all needed nodes into varpool.
We however don't want to re-analyze already analyzed nodes. */
- if (!node->analyzed)
+ if (!node->symbol.analyzed)
{
gcc_assert (!in_lto_p || cgraph_function_flags_ready);
/* Compute the alignment early so function body expanders are
already informed about increased alignment. */
align_variable (decl, 0);
}
- if (node->alias && node->alias_of)
+ if (node->symbol.alias && node->alias_of)
{
struct varpool_node *tgt = varpool_node_for_decl (node->alias_of);
struct varpool_node *n;
- for (n = tgt; n && n->alias;
- n = n->analyzed ? varpool_alias_aliased_node (n) : NULL)
+ for (n = tgt; n && n->symbol.alias;
+ n = n->symbol.analyzed ? varpool_alias_target (n) : NULL)
if (n == node)
{
error ("variable %q+D part of alias cycle", node->symbol.decl);
- node->alias = false;
+ node->symbol.alias = false;
continue;
}
if (!vec_safe_length (node->symbol.ref_list.references))
@@ -257,8 +265,8 @@ varpool_analyze_node (struct varpool_node *node)
}
}
else if (DECL_INITIAL (decl))
- record_references_in_initializer (decl, node->analyzed);
- node->analyzed = true;
+ record_references_in_initializer (decl, node->symbol.analyzed);
+ node->symbol.analyzed = true;
}
/* Assemble thunks and aliases associated to NODE. */
@@ -287,7 +295,7 @@ varpool_assemble_decl (struct varpool_node *node)
/* Aliases are outout when their target is produced or by
output_weakrefs. */
- if (node->alias)
+ if (node->symbol.alias)
return false;
/* Constant pool is output from RTL land when the reference
@@ -316,7 +324,7 @@ varpool_assemble_decl (struct varpool_node *node)
{
assemble_variable (decl, 0, 1, 0);
gcc_assert (TREE_ASM_WRITTEN (decl));
- node->finalized = 1;
+ node->symbol.definition = true;
assemble_aliases (node);
return true;
}
@@ -357,7 +365,7 @@ varpool_remove_unreferenced_decls (void)
fprintf (cgraph_dump_file, "Trivially needed variables:");
FOR_EACH_DEFINED_VARIABLE (node)
{
- if (node->analyzed
+ if (node->symbol.analyzed
&& (!varpool_can_remove_if_no_refs (node)
/* We just expanded all function bodies. See if any of
them needed the variable. */
@@ -381,7 +389,7 @@ varpool_remove_unreferenced_decls (void)
next = next->symbol.same_comdat_group)
{
varpool_node *vnext = dyn_cast <varpool_node> (next);
- if (vnext && vnext->analyzed)
+ if (vnext && vnext->symbol.analyzed)
enqueue_node (vnext, &first);
}
}
@@ -390,8 +398,8 @@ varpool_remove_unreferenced_decls (void)
varpool_node *vnode = dyn_cast <varpool_node> (ref->referred);
if (vnode
&& (!DECL_EXTERNAL (ref->referred->symbol.decl)
- || vnode->alias)
- && vnode->analyzed)
+ || vnode->symbol.alias)
+ && vnode->symbol.analyzed)
enqueue_node (vnode, &first);
}
}
@@ -419,7 +427,7 @@ void
varpool_finalize_named_section_flags (struct varpool_node *node)
{
if (!TREE_ASM_WRITTEN (node->symbol.decl)
- && !node->alias
+ && !node->symbol.alias
&& !node->symbol.in_other_partition
&& !DECL_EXTERNAL (node->symbol.decl)
&& TREE_CODE (node->symbol.decl) == VAR_DECL
@@ -484,8 +492,8 @@ varpool_create_variable_alias (tree alias, tree decl)
gcc_assert (TREE_CODE (decl) == VAR_DECL);
gcc_assert (TREE_CODE (alias) == VAR_DECL);
alias_node = varpool_node_for_decl (alias);
- alias_node->alias = 1;
- alias_node->finalized = 1;
+ alias_node->symbol.alias = true;
+ alias_node->symbol.definition = true;
alias_node->alias_of = decl;
/* Extra name alias mechanizm creates aliases really late