From: Jan Hubicka Date: Sun, 16 Nov 2014 19:36:37 +0000 (+0100) Subject: passes.c (execute_one_pass): Do not apply all transforms prior every simple IPA pass. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=70486010428fdaeabd875022fee05122e9866424;p=gcc.git passes.c (execute_one_pass): Do not apply all transforms prior every simple IPA pass. * passes.c (execute_one_pass): Do not apply all transforms prior every simple IPA pass. * cgraphunit.c: Do not include fibheap.h (expand_thunk): Use get_untransformed_body. (cgraph_node::expand): Likewise. * tree-ssa-structalias.c (ipa_pta_execute): Skip inline clones. * cgraph.c (release_function_body): Do not push cfun when CFG is not there. (cgraph_node::get_untransformed_body): Break out from ... (cgraph_node::get_body): ... here; add code to apply all transforms. * cgraph.h (cgraph_node): Add get_untransformed_body. * ipa-icf.c (sem_function::init): Use get_untransformed_body. * cgraphclones.c (duplicate_thunk_for_node): Likewise. * tree-inline.c (expand_call_inline): LIkewise. * i386.c (ix86_reset_to_default_globals): Break out from ... (ix86_set_current_function): ... here; (ix86_reset_previous_fndecl): Use it. (ix86_simd_clone_adjust): Use ix86_reset_previous_fndecl. From-SVN: r217633 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 69bed229701..d035fe15e20 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,23 @@ +2014-11-16 Jan Hubicka + + * passes.c (execute_one_pass): Do not apply all transforms prior + every simple IPA pass. + * cgraphunit.c: Do not include fibheap.h + (expand_thunk): Use get_untransformed_body. + (cgraph_node::expand): Likewise. + * tree-ssa-structalias.c (ipa_pta_execute): Skip inline clones. + * cgraph.c (release_function_body): Do not push cfun when CFG is not there. + (cgraph_node::get_untransformed_body): Break out from ... + (cgraph_node::get_body): ... here; add code to apply all transforms. + * cgraph.h (cgraph_node): Add get_untransformed_body. + * ipa-icf.c (sem_function::init): Use get_untransformed_body. + * cgraphclones.c (duplicate_thunk_for_node): Likewise. + * tree-inline.c (expand_call_inline): LIkewise. + * i386.c (ix86_reset_to_default_globals): Break out from ... + (ix86_set_current_function): ... here; + (ix86_reset_previous_fndecl): Use it. + (ix86_simd_clone_adjust): Use ix86_reset_previous_fndecl. + 2014-11-16 Eric Botcazou * doc/tm.texi.in (TARGET_FLAGS_REGNUM): Move around. diff --git a/gcc/cgraph.c b/gcc/cgraph.c index a66c9c0ea75..ad181b062c8 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1664,29 +1664,33 @@ release_function_body (tree decl) { if (DECL_STRUCT_FUNCTION (decl)) { - push_cfun (DECL_STRUCT_FUNCTION (decl)); - if (cfun->cfg - && current_loops) - { - cfun->curr_properties &= ~PROP_loops; - loop_optimizer_finalize (); - } - if (cfun->gimple_df) + if (DECL_STRUCT_FUNCTION (decl)->cfg + || DECL_STRUCT_FUNCTION (decl)->gimple_df) { - delete_tree_ssa (); - delete_tree_cfg_annotations (); - cfun->eh = NULL; - } - if (cfun->cfg) - { - gcc_assert (!dom_info_available_p (CDI_DOMINATORS)); - gcc_assert (!dom_info_available_p (CDI_POST_DOMINATORS)); - clear_edges (); - cfun->cfg = NULL; + push_cfun (DECL_STRUCT_FUNCTION (decl)); + if (cfun->cfg + && current_loops) + { + cfun->curr_properties &= ~PROP_loops; + loop_optimizer_finalize (); + } + if (cfun->gimple_df) + { + delete_tree_ssa (); + delete_tree_cfg_annotations (); + cfun->eh = NULL; + } + if (cfun->cfg) + { + gcc_assert (!dom_info_available_p (CDI_DOMINATORS)); + gcc_assert (!dom_info_available_p (CDI_POST_DOMINATORS)); + clear_edges (); + cfun->cfg = NULL; + } + if (cfun->value_histograms) + free_histograms (); + pop_cfun (); } - if (cfun->value_histograms) - free_histograms (); - pop_cfun (); gimple_set_body (decl, NULL); /* Struct function hangs a lot of data that would leak if we didn't removed all pointers to it. */ @@ -3138,7 +3142,7 @@ cgraph_node::function_symbol (enum availability *availability) present. */ bool -cgraph_node::get_body (void) +cgraph_node::get_untransformed_body (void) { lto_file_decl_data *file_data; const char *data, *name; @@ -3178,6 +3182,44 @@ cgraph_node::get_body (void) return true; } +/* Prepare function body. When doing LTO, read cgraph_node's body from disk + if it is not already present. When some IPA transformations are scheduled, + apply them. */ + +bool +cgraph_node::get_body (void) +{ + bool updated; + + updated = get_untransformed_body (); + + /* Getting transformed body makes no sense for inline clones; + we should never use this on real clones becuase they are materialized + early. + TODO: Materializing clones here will likely lead to smaller LTRANS + footprint. */ + gcc_assert (!global.inlined_to && !clone_of); + if (ipa_transforms_to_apply.exists ()) + { + opt_pass *saved_current_pass = current_pass; + FILE *saved_dump_file = dump_file; + int saved_dump_flags = dump_flags; + + push_cfun (DECL_STRUCT_FUNCTION (decl)); + execute_all_ipa_transforms (); + cgraph_edge::rebuild_edges (); + free_dominance_info (CDI_DOMINATORS); + free_dominance_info (CDI_POST_DOMINATORS); + pop_cfun (); + updated = true; + + current_pass = saved_current_pass; + dump_file = saved_dump_file; + dump_flags = saved_dump_flags; + } + return updated; +} + /* Return the DECL_STRUCT_FUNCTION of the function. */ struct function * diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 5d949abc722..77c2a6058e7 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -933,6 +933,11 @@ public: /* When doing LTO, read cgraph_node's body from disk if it is not already present. */ + bool get_untransformed_body (void); + + /* Prepare function body. When doing LTO, read cgraph_node's body from disk + if it is not already present. When some IPA transformations are scheduled, + apply them. */ bool get_body (void); /* Release memory used to represent body of function. diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c index c8892daf52d..7dc96f1d5ba 100644 --- a/gcc/cgraphclones.c +++ b/gcc/cgraphclones.c @@ -307,7 +307,7 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node) node = duplicate_thunk_for_node (thunk_of, node); if (!DECL_ARGUMENTS (thunk->decl)) - thunk->get_body (); + thunk->get_untransformed_body (); cgraph_edge *cs; for (cs = node->callers; cs; cs = cs->next_caller) @@ -1067,7 +1067,7 @@ symbol_table::materialize_all_clones (void) && !gimple_has_body_p (node->decl)) { if (!node->clone_of->clone_of) - node->clone_of->get_body (); + node->clone_of->get_untransformed_body (); if (gimple_has_body_p (node->clone_of->decl)) { if (symtab->dump_file) diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 534c61301d0..4fba9ff59ce 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -197,7 +197,6 @@ along with GCC; see the file COPYING3. If not see #include "target.h" #include "diagnostic.h" #include "params.h" -#include "fibheap.h" #include "intl.h" #include "hash-map.h" #include "plugin-api.h" @@ -1469,7 +1468,7 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk) } if (in_lto_p) - get_body (); + get_untransformed_body (); a = DECL_ARGUMENTS (thunk_fndecl); current_function_decl = thunk_fndecl; @@ -1522,7 +1521,7 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk) gimple ret; if (in_lto_p) - get_body (); + get_untransformed_body (); a = DECL_ARGUMENTS (thunk_fndecl); current_function_decl = thunk_fndecl; @@ -1744,7 +1743,7 @@ cgraph_node::expand (void) announce_function (decl); process = 0; gcc_assert (lowered); - get_body (); + get_untransformed_body (); /* Generate RTL for the body of DECL. */ diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 3400ca3d577..7942cec4595 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -5029,10 +5029,35 @@ ix86_can_inline_p (tree caller, tree callee) /* Remember the last target of ix86_set_current_function. */ static GTY(()) tree ix86_previous_fndecl; +/* Set target globals to default. */ + +static void +ix86_reset_to_default_globals (void) +{ + tree old_tree = (ix86_previous_fndecl + ? DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl) + : NULL_TREE); + + if (old_tree) + { + tree new_tree = target_option_current_node; + cl_target_option_restore (&global_options, + TREE_TARGET_OPTION (new_tree)); + if (TREE_TARGET_GLOBALS (new_tree)) + restore_target_globals (TREE_TARGET_GLOBALS (new_tree)); + else if (new_tree == target_option_default_node) + restore_target_globals (&default_target_globals); + else + TREE_TARGET_GLOBALS (new_tree) + = save_target_globals_default_opts (); + } +} + /* Invalidate ix86_previous_fndecl cache. */ void ix86_reset_previous_fndecl (void) { + ix86_reset_to_default_globals (); ix86_previous_fndecl = NULL_TREE; } @@ -5055,7 +5080,6 @@ ix86_set_current_function (tree fndecl) ? DECL_FUNCTION_SPECIFIC_TARGET (fndecl) : NULL_TREE); - ix86_previous_fndecl = fndecl; if (old_tree == new_tree) ; @@ -5071,18 +5095,8 @@ ix86_set_current_function (tree fndecl) } else if (old_tree) - { - new_tree = target_option_current_node; - cl_target_option_restore (&global_options, - TREE_TARGET_OPTION (new_tree)); - if (TREE_TARGET_GLOBALS (new_tree)) - restore_target_globals (TREE_TARGET_GLOBALS (new_tree)); - else if (new_tree == target_option_default_node) - restore_target_globals (&default_target_globals); - else - TREE_TARGET_GLOBALS (new_tree) - = save_target_globals_default_opts (); - } + ix86_reset_to_default_globals (); + ix86_previous_fndecl = fndecl; } } @@ -50972,7 +50986,7 @@ ix86_simd_clone_adjust (struct cgraph_node *node) bool ok = ix86_valid_target_attribute_p (node->decl, NULL, args, 0); gcc_assert (ok); pop_cfun (); - ix86_previous_fndecl = NULL_TREE; + ix86_reset_previous_fndecl (); ix86_set_current_function (node->decl); } diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index 92ec82d7c8a..2d5fcf56b42 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -706,7 +706,7 @@ void sem_function::init (void) { if (in_lto_p) - get_node ()->get_body (); + get_node ()->get_untransformed_body (); tree fndecl = node->decl; function *func = DECL_STRUCT_FUNCTION (fndecl); diff --git a/gcc/passes.c b/gcc/passes.c index aa40fe5fa30..c818d8ad919 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -2214,36 +2214,6 @@ execute_one_pass (opt_pass *pass) executed. */ invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION, pass); - /* SIPLE IPA passes do not handle callgraphs with IPA transforms in it. - Apply all trnasforms first. */ - if (pass->type == SIMPLE_IPA_PASS) - { - struct cgraph_node *node; - bool applied = false; - FOR_EACH_DEFINED_FUNCTION (node) - if (node->analyzed - && node->has_gimple_body_p () - && (!node->clone_of || node->decl != node->clone_of->decl)) - { - if (!node->global.inlined_to - && node->ipa_transforms_to_apply.exists ()) - { - node->get_body (); - push_cfun (DECL_STRUCT_FUNCTION (node->decl)); - execute_all_ipa_transforms (); - cgraph_edge::rebuild_edges (); - free_dominance_info (CDI_DOMINATORS); - free_dominance_info (CDI_POST_DOMINATORS); - pop_cfun (); - applied = true; - } - } - if (applied) - symtab->remove_unreachable_nodes (false, dump_file); - /* Restore current_pass. */ - current_pass = pass; - } - if (!quiet_flag && !cfun) fprintf (stderr, " <%s>", pass->name ? pass->name : ""); diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 520546e3d09..510b53ee416 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4338,7 +4338,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) goto egress; } fn = cg_edge->callee->decl; - cg_edge->callee->get_body (); + cg_edge->callee->get_untransformed_body (); #ifdef ENABLE_CHECKING if (cg_edge->callee->decl != id->dst_node->decl) diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 36213772f4c..7157693e5d0 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -7086,7 +7086,7 @@ ipa_pta_execute (void) /* Nodes without a body are not interesting. Especially do not visit clones at this point for now - we get duplicate decls there for inline clones at least. */ - if (!node->has_gimple_body_p () || node->clone_of) + if (!node->has_gimple_body_p () || node->global.inlined_to) continue; node->get_body ();