From 59dd48301d310463d3fffaf4c68d8df57fa20073 Mon Sep 17 00:00:00 2001 From: hubicka Date: Wed, 7 Oct 2009 09:01:16 +0000 Subject: * lto-symtab.c (lto_cgraph_replace_node): Assert that inline clones has no address taken. * cgraph.c (cgraph_mark_needed_node): Assert that inline clones are never needed. (cgraph_clone_node): Clear externally_visible flag for clones. * cgraph.h (cgraph_only_called_directly_p, cgraph_can_remove_if_no_direct_calls_p): New predicates. * tree-pass.h (pass_ipa_whole_program_visibility): Declare. * ipa-cp.c (ipcp_cloning_candidate_p): Use new predicate. (ipcp_initialize_node_lattices, ipcp_estimate_growth, ipcp_insert_stage): Likwise. * cgraphunit.c (cgraph_decide_is_function_needed): Do not compute externally_visible flag. (verify_cgraph_node): Verify that inline clones look right. (process_function_and_variable_attributes): Do not set externally_visible flags. (ipa_passes): Avoid executing small_ipa_passes at LTO stage; they've been already run. * lto-cgraph.c (lto_output_node): Assert that inline clones are not boundaries. * ipa-inline.c (cgraph_clone_inlined_nodes): Use new predicates; clear externally_visible when turning into inline clones (cgraph_mark_inline_edge): Use new predicates. (cgraph_estimate_growth): Likewise. (cgraph_decide_inlining): Likewise. * ipa.c (cgraph_postorder): Likewise. (cgraph_remove_unreachable_nodes): Likewise; sanity check that inline clones are not needed. (cgraph_externally_visible_p): New predicate. (function_and_variable_visibility): Add whole_program parameter; always set externally_visible flag; handle COMDAT function privatization. (local_function_and_variable_visibility): New function. (gate_whole_program_function_and_variable_visibility): New function. (whole_program_function_and_variable_visibility): New function. (pass_ipa_whole_program_visibility): New function. * passes.c (init_optimization_passes): Add whole program visibility pass. (do_per_function_toporder, function_called_by_processed_nodes_p): Do not care about needed/reachable flags. * varpool.c: Include flags.h (decide_is_variable_needed): When doing LTO assume whole-program mode. (varpool_finalize_decl): When we are in LTO read-back, all variables are analyzed. (varpool_analyze_pending_decls): Skip analyzis of analyzed vars. * lto/lto.c (read_cgraph_and_symbols): Mark functions neccesary only at ltrans stage; explain why this is needed and should not. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152520 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cgraphunit.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'gcc/cgraphunit.c') diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 9a4f63d3aca..9a97bef2962 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -316,13 +316,6 @@ cgraph_build_cdtor_fns (void) bool cgraph_decide_is_function_needed (struct cgraph_node *node, tree decl) { - if (MAIN_NAME_P (DECL_NAME (decl)) - && TREE_PUBLIC (decl)) - { - node->local.externally_visible = true; - return true; - } - /* If the user told us it is used, then it must be so. */ if (node->local.externally_visible) return true; @@ -360,7 +353,9 @@ cgraph_decide_is_function_needed (struct cgraph_node *node, tree decl) || (!optimize && !node->local.disregard_inline_limits && !DECL_DECLARED_INLINE_P (decl) && !node->origin)) - && !flag_whole_program) + && !flag_whole_program + && !flag_lto + && !flag_whopr) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl)) return true; @@ -593,6 +588,21 @@ verify_cgraph_node (struct cgraph_node *node) error ("Execution count is negative"); error_found = true; } + if (node->global.inlined_to && node->local.externally_visible) + { + error ("Externally visible inline clone"); + error_found = true; + } + if (node->global.inlined_to && node->address_taken) + { + error ("Inline clone with address taken"); + error_found = true; + } + if (node->global.inlined_to && node->needed) + { + error ("Inline clone is needed"); + error_found = true; + } for (e = node->callers; e; e = e->next_caller) { if (e->count < 0) @@ -864,12 +874,8 @@ process_function_and_variable_attributes (struct cgraph_node *first, warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wattributes, "%" " attribute have effect only on public objects"); - else - { - if (node->local.finalized) - cgraph_mark_needed_node (node); - node->local.externally_visible = true; - } + else if (node->local.finalized) + cgraph_mark_needed_node (node); } } for (vnode = varpool_nodes; vnode != first_var; vnode = vnode->next) @@ -887,12 +893,8 @@ process_function_and_variable_attributes (struct cgraph_node *first, warning_at (DECL_SOURCE_LOCATION (vnode->decl), OPT_Wattributes, "%" " attribute have effect only on public objects"); - else - { - if (vnode->finalized) - varpool_mark_needed_node (vnode); - vnode->externally_visible = true; - } + else if (vnode->finalized) + varpool_mark_needed_node (vnode); } } } @@ -1355,7 +1357,9 @@ ipa_passes (void) current_function_decl = NULL; gimple_register_cfg_hooks (); bitmap_obstack_initialize (NULL); - execute_ipa_pass_list (all_small_ipa_passes); + + if (!in_lto_p) + execute_ipa_pass_list (all_small_ipa_passes); /* If pass_all_early_optimizations was not scheduled, the state of the cgraph will not be properly updated. Update it now. */ -- cgit v1.2.1