aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraphunit.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/cgraphunit.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/cgraphunit.c')
-rw-r--r--gcc/cgraphunit.c117
1 files changed, 53 insertions, 64 deletions
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 6ebf8d4..ca314a6 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -202,7 +202,7 @@ cgraph_node_set cgraph_new_nodes;
static void expand_all_functions (void);
static void mark_functions_to_output (void);
static void expand_function (struct cgraph_node *);
-static void cgraph_analyze_function (struct cgraph_node *);
+static void analyze_function (struct cgraph_node *);
static void handle_alias_pairs (void);
FILE *cgraph_dump_file;
@@ -309,8 +309,8 @@ cgraph_process_new_functions (void)
cgraph but not on this function. */
gimple_register_cfg_hooks ();
- if (!node->analyzed)
- cgraph_analyze_function (node);
+ if (!node->symbol.analyzed)
+ analyze_function (node);
push_cfun (DECL_STRUCT_FUNCTION (fndecl));
if ((cgraph_state == CGRAPH_STATE_IPA_SSA
&& !gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl)))
@@ -354,7 +354,7 @@ cgraph_process_new_functions (void)
??? It may make more sense to use one body for inlining and other
body for expanding the function but this is difficult to do. */
-static void
+void
cgraph_reset_node (struct cgraph_node *node)
{
/* If node->process is set, then we have already begun whole-unit analysis.
@@ -368,10 +368,11 @@ cgraph_reset_node (struct cgraph_node *node)
memset (&node->local, 0, sizeof (node->local));
memset (&node->global, 0, sizeof (node->global));
memset (&node->rtl, 0, sizeof (node->rtl));
- node->analyzed = false;
- node->local.finalized = false;
+ node->symbol.analyzed = false;
+ node->symbol.definition = false;
cgraph_node_remove_callees (node);
+ ipa_remove_all_references (&node->symbol.ref_list);
}
/* Return true when there are references to NODE. */
@@ -401,14 +402,14 @@ cgraph_finalize_function (tree decl, bool nested)
{
struct cgraph_node *node = cgraph_get_create_node (decl);
- if (node->local.finalized)
+ if (node->symbol.definition)
{
cgraph_reset_node (node);
node->local.redefined_extern_inline = true;
}
notice_global_symbol (decl);
- node->local.finalized = true;
+ node->symbol.definition = true;
node->lowered = DECL_STRUCT_FUNCTION (decl)->cfg != NULL;
/* With -fkeep-inline-functions we are keeping all inline functions except
@@ -488,7 +489,7 @@ cgraph_add_new_function (tree fndecl, bool lowered)
analyzing and compilation. */
node = cgraph_get_create_node (fndecl);
node->local.local = false;
- node->local.finalized = true;
+ node->symbol.definition = true;
node->symbol.force_output = true;
if (!lowered && cgraph_state == CGRAPH_STATE_EXPANSION)
{
@@ -515,7 +516,8 @@ cgraph_add_new_function (tree fndecl, bool lowered)
node = cgraph_create_node (fndecl);
if (lowered)
node->lowered = true;
- cgraph_analyze_function (node);
+ node->symbol.definition = true;
+ analyze_function (node);
push_cfun (DECL_STRUCT_FUNCTION (fndecl));
gimple_register_cfg_hooks ();
bitmap_obstack_initialize (NULL);
@@ -589,23 +591,23 @@ fixup_same_cpp_alias_visibility (symtab_node node, symtab_node target, tree alia
/* Analyze the function scheduled to be output. */
static void
-cgraph_analyze_function (struct cgraph_node *node)
+analyze_function (struct cgraph_node *node)
{
tree decl = node->symbol.decl;
location_t saved_loc = input_location;
input_location = DECL_SOURCE_LOCATION (decl);
- if (node->alias && node->thunk.alias)
+ if (node->symbol.alias && node->thunk.alias)
{
struct cgraph_node *tgt = cgraph_get_node (node->thunk.alias);
struct cgraph_node *n;
- for (n = tgt; n && n->alias;
- n = n->analyzed ? cgraph_alias_aliased_node (n) : NULL)
+ for (n = tgt; n && n->symbol.alias;
+ n = n->symbol.analyzed ? cgraph_alias_target (n) : NULL)
if (n == node)
{
error ("function %q+D part of alias cycle", node->symbol.decl);
- node->alias = false;
+ node->symbol.alias = false;
input_location = saved_loc;
return;
}
@@ -622,7 +624,7 @@ cgraph_analyze_function (struct cgraph_node *node)
}
if (node->symbol.address_taken)
- cgraph_mark_address_taken_node (cgraph_alias_aliased_node (node));
+ cgraph_mark_address_taken_node (cgraph_alias_target (node));
}
else if (node->thunk.thunk_p)
{
@@ -677,7 +679,7 @@ cgraph_analyze_function (struct cgraph_node *node)
pop_cfun ();
}
- node->analyzed = true;
+ node->symbol.analyzed = true;
input_location = saved_loc;
}
@@ -766,7 +768,7 @@ process_function_and_variable_attributes (struct cgraph_node *first,
" attribute have effect only on public objects");
}
if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))
- && (node->local.finalized && !node->alias))
+ && (node->symbol.definition && !node->symbol.alias))
{
warning_at (DECL_SOURCE_LOCATION (node->symbol.decl), OPT_Wattributes,
"%<weakref%> attribute ignored"
@@ -803,7 +805,7 @@ process_function_and_variable_attributes (struct cgraph_node *first,
" attribute have effect only on public objects");
}
if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))
- && vnode->finalized
+ && vnode->symbol.definition
&& DECL_INITIAL (decl))
{
warning_at (DECL_SOURCE_LOCATION (vnode->symbol.decl), OPT_Wattributes,
@@ -828,10 +830,10 @@ varpool_finalize_decl (tree decl)
gcc_assert (TREE_STATIC (decl) || DECL_EXTERNAL (decl));
- if (node->finalized)
+ if (node->symbol.definition)
return;
notice_global_symbol (decl);
- node->finalized = true;
+ node->symbol.definition = true;
if (TREE_THIS_VOLATILE (decl) || DECL_PRESERVE_P (decl)
/* Traditionally we do not eliminate static variables when not
optimizing and when not doing toplevel reoder. */
@@ -855,36 +857,23 @@ varpool_finalize_decl (tree decl)
/* Determine if a symbol NODE is finalized and needed. */
inline static bool
-symbol_finalized_and_needed (symtab_node node)
+symbol_defined_and_needed (symtab_node node)
{
if (cgraph_node *cnode = dyn_cast <cgraph_node> (node))
- return cnode->local.finalized
+ return cnode->symbol.definition
&& cgraph_decide_is_function_needed (cnode, cnode->symbol.decl);
if (varpool_node *vnode = dyn_cast <varpool_node> (node))
- return vnode->finalized
+ return vnode->symbol.definition
&& !DECL_EXTERNAL (vnode->symbol.decl)
&& decide_is_variable_needed (vnode, vnode->symbol.decl);
return false;
}
-/* Determine if a symbol NODE is finalized. */
-
-inline static bool
-symbol_finalized (symtab_node node)
-{
- if (cgraph_node *cnode= dyn_cast <cgraph_node> (node))
- return cnode->local.finalized;
- if (varpool_node *vnode = dyn_cast <varpool_node> (node))
- return vnode->finalized;
- return false;
-}
-
-
/* Discover all functions and variables that are trivially needed, analyze
them as well as all functions and variables referred by them */
static void
-cgraph_analyze_functions (void)
+analyze_functions (void)
{
/* Keep track of already processed nodes when called multiple times for
intermodule optimization. */
@@ -914,7 +903,7 @@ cgraph_analyze_functions (void)
node != (symtab_node)first_analyzed
&& node != (symtab_node)first_analyzed_var; node = node->symbol.next)
{
- if (symbol_finalized_and_needed (node))
+ if (symbol_defined_and_needed (node))
{
enqueue_node (node);
if (!changed && cgraph_dump_file)
@@ -942,7 +931,7 @@ cgraph_analyze_functions (void)
node = first;
first = (symtab_node)first->symbol.aux;
cgraph_node *cnode = dyn_cast <cgraph_node> (node);
- if (cnode && cnode->local.finalized)
+ if (cnode && cnode->symbol.definition)
{
struct cgraph_edge *edge;
tree decl = cnode->symbol.decl;
@@ -951,7 +940,7 @@ cgraph_analyze_functions (void)
and later using weak alias attribute to kill its body.
See gcc.c-torture/compile/20011119-1.c */
if (!DECL_STRUCT_FUNCTION (decl)
- && (!cnode->alias || !cnode->thunk.alias)
+ && (!cnode->symbol.alias || !cnode->thunk.alias)
&& !cnode->thunk.thunk_p
&& !cnode->dispatcher_function)
{
@@ -960,11 +949,11 @@ cgraph_analyze_functions (void)
continue;
}
- if (!cnode->analyzed)
- cgraph_analyze_function (cnode);
+ if (!cnode->symbol.analyzed)
+ analyze_function (cnode);
for (edge = cnode->callees; edge; edge = edge->next_callee)
- if (edge->callee->local.finalized)
+ if (edge->callee->symbol.definition)
enqueue_node ((symtab_node)edge->callee);
/* If decl is a clone of an abstract function,
@@ -981,7 +970,7 @@ cgraph_analyze_functions (void)
else
{
varpool_node *vnode = dyn_cast <varpool_node> (node);
- if (vnode && vnode->finalized)
+ if (vnode && vnode->symbol.definition)
varpool_analyze_node (vnode);
}
@@ -994,7 +983,7 @@ cgraph_analyze_functions (void)
enqueue_node (next);
}
for (i = 0; ipa_ref_list_reference_iterate (&node->symbol.ref_list, i, ref); i++)
- if (symbol_finalized (ref->referred))
+ if (ref->referred->symbol.definition)
enqueue_node (ref->referred);
cgraph_process_new_functions ();
}
@@ -1026,15 +1015,15 @@ cgraph_analyze_functions (void)
{
tree decl = node->symbol.decl;
- if (cnode->local.finalized && !gimple_has_body_p (decl)
- && (!cnode->alias || !cnode->thunk.alias)
+ if (cnode->symbol.definition && !gimple_has_body_p (decl)
+ && (!cnode->symbol.alias || !cnode->thunk.alias)
&& !cnode->thunk.thunk_p)
cgraph_reset_node (cnode);
- gcc_assert (!cnode->local.finalized || cnode->thunk.thunk_p
- || cnode->alias
+ gcc_assert (!cnode->symbol.definition || cnode->thunk.thunk_p
+ || cnode->symbol.alias
|| gimple_has_body_p (decl));
- gcc_assert (cnode->analyzed == cnode->local.finalized);
+ gcc_assert (cnode->symbol.analyzed == cnode->symbol.definition);
}
node->symbol.aux = NULL;
}
@@ -1071,13 +1060,13 @@ handle_alias_pairs (void)
if (TREE_CODE (p->decl) == FUNCTION_DECL)
{
struct cgraph_node *anode = cgraph_get_create_node (p->decl);
- anode->alias = true;
+ anode->symbol.alias = true;
anode->thunk.alias = p->target;
}
else
{
struct varpool_node *anode = varpool_get_node (p->decl);
- anode->alias = true;
+ anode->symbol.alias = true;
anode->alias_of = p->target;
}
DECL_EXTERNAL (p->decl) = 1;
@@ -1117,7 +1106,7 @@ handle_alias_pairs (void)
&& target_node && is_a <cgraph_node> (target_node))
{
struct cgraph_node *src_node = cgraph_get_node (p->decl);
- if (src_node && src_node->local.finalized)
+ if (src_node && src_node->symbol.definition)
cgraph_reset_node (src_node);
cgraph_create_function_alias (p->decl, target_node->symbol.decl);
alias_pairs->unordered_remove (i);
@@ -1165,9 +1154,9 @@ mark_functions_to_output (void)
/* We need to output all local functions that are used and not
always inlined, as well as those that are reachable from
outside the current compilation unit. */
- if (node->analyzed
+ if (node->symbol.analyzed
&& !node->thunk.thunk_p
- && !node->alias
+ && !node->symbol.alias
&& !node->global.inlined_to
&& !TREE_ASM_WRITTEN (decl)
&& !DECL_EXTERNAL (decl))
@@ -1179,7 +1168,7 @@ mark_functions_to_output (void)
for (next = cgraph (node->symbol.same_comdat_group);
next != node;
next = cgraph (next->symbol.same_comdat_group))
- if (!next->thunk.thunk_p && !next->alias)
+ if (!next->thunk.thunk_p && !next->symbol.alias)
next->process = 1;
}
}
@@ -1199,7 +1188,7 @@ mark_functions_to_output (void)
are inside partition, we can end up not removing the body since we no longer
have analyzed node pointing to it. */
&& !node->symbol.in_other_partition
- && !node->alias
+ && !node->symbol.alias
&& !node->clones
&& !DECL_EXTERNAL (decl))
{
@@ -1435,7 +1424,7 @@ assemble_thunk (struct cgraph_node *node)
set_cfun (NULL);
TREE_ASM_WRITTEN (thunk_fndecl) = 1;
node->thunk.thunk_p = false;
- node->analyzed = false;
+ node->symbol.analyzed = false;
}
else
{
@@ -1800,7 +1789,7 @@ output_in_order (void)
FOR_EACH_DEFINED_FUNCTION (pf)
{
- if (pf->process && !pf->thunk.thunk_p && !pf->alias)
+ if (pf->process && !pf->thunk.thunk_p && !pf->symbol.alias)
{
i = pf->symbol.order;
gcc_assert (nodes[i].kind == ORDER_UNDEFINED);
@@ -1943,14 +1932,14 @@ output_weakrefs (void)
struct cgraph_node *node;
struct varpool_node *vnode;
FOR_EACH_FUNCTION (node)
- if (node->alias && DECL_EXTERNAL (node->symbol.decl)
+ if (node->symbol.alias && DECL_EXTERNAL (node->symbol.decl)
&& !TREE_ASM_WRITTEN (node->symbol.decl)
&& lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
do_assemble_alias (node->symbol.decl,
node->thunk.alias && DECL_P (node->thunk.alias) ? DECL_ASSEMBLER_NAME (node->thunk.alias)
: get_alias_symbol (node->symbol.decl));
FOR_EACH_VARIABLE (vnode)
- if (vnode->alias && DECL_EXTERNAL (vnode->symbol.decl)
+ if (vnode->symbol.alias && DECL_EXTERNAL (vnode->symbol.decl)
&& !TREE_ASM_WRITTEN (vnode->symbol.decl)
&& lookup_attribute ("weakref", DECL_ATTRIBUTES (vnode->symbol.decl)))
do_assemble_alias (vnode->symbol.decl,
@@ -2115,13 +2104,13 @@ finalize_compilation_unit (void)
/* Gimplify and lower all functions, compute reachability and
remove unreachable nodes. */
- cgraph_analyze_functions ();
+ analyze_functions ();
/* Mark alias targets necessary and emit diagnostics. */
handle_alias_pairs ();
/* Gimplify and lower thunks. */
- cgraph_analyze_functions ();
+ analyze_functions ();
/* Finally drive the pass manager. */
compile ();