From d2db2e6b0563787bcc40c025ae5888020ded364f Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Tue, 23 May 2017 18:20:53 +0200 Subject: [PATCH] cgraphunit.c (symbol_table::process_new_functions): Update. * cgraphunit.c (symbol_table::process_new_functions): Update. * ipa-fnsummary.c (pass_data_inline_parameters): Remove. (inline_generate_summary): Rename to ... (ipa_fn_summary_generate): ... this one. (inline_read_summary): Rename to ... (ipa_fn_summary_read): ... this one. (inline_write_summary): Rename to ... (ipa_fn_summary_write): ... this one. (inline_free_summary): Rename to ... (ipa_free_fn_summary): ... this one. (pass_data_local_fn_summary, pass_local_fn_summary, make_pass_local_fn_summary, pass_data_ipa_free_fn_summary, pass_ipa_free_fn_summary, make_pass_ipa_free_fn_summary, pass_data_ipa_fn_summary, pass_ipa_fn_summary, make_pass_ipa_fn_summary): New. * ipa-fnsummary.h (inline_generate_summary, inline_read_summary, inline_write_summary, inline_free_summary): Remove. (ipa_free_fn_summary) : New. * ipa-inline.c (ipa_inline): Update. (pass_ipa_inline): Do not generate summaries. * ipa.c (pass_data_ipa_free_fn_summary, pass_ipa_free_fn_summary): Remove. * passes.def: Replace pass_inline_parameters by pass_local_fn_summary and add pass_ipa_fn_summary. * tree-pass.h (make_pass_ipa_fn_summary, make_pass_local_fn_summary): New. (make_pass_inline_parameters): Remove. * lto.c (do_whole_program_analysis): Replace inline_free_summary by ipa_free_fn_summary. * gcc.dg/ipa/ctor-empty-1.c: Update template. * gcc.dg/ipa/inline-5.c: Likewise. * gfortran.dg/pr48636.f90: Likewise. From-SVN: r248375 --- gcc/ChangeLog | 30 ++++ gcc/cgraphunit.c | 2 +- gcc/ipa-fnsummary.c | 184 +++++++++++++++++------- gcc/ipa-fnsummary.h | 5 +- gcc/ipa-inline.c | 8 +- gcc/ipa.c | 44 ------ gcc/lto/ChangeLog | 5 + gcc/lto/lto.c | 2 +- gcc/passes.def | 5 +- gcc/testsuite/ChangeLog | 6 + gcc/testsuite/gcc.dg/ipa/ctor-empty-1.c | 4 +- gcc/testsuite/gcc.dg/ipa/inline-5.c | 6 +- gcc/testsuite/gfortran.dg/pr48636.f90 | 6 +- gcc/tree-pass.h | 3 +- 14 files changed, 197 insertions(+), 113 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b626515cfb7..57849a84e23 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,33 @@ +2017-05-23 Jan Hubicka + + * cgraphunit.c (symbol_table::process_new_functions): Update. + * ipa-fnsummary.c (pass_data_inline_parameters): Remove. + (inline_generate_summary): Rename to ... + (ipa_fn_summary_generate): ... this one. + (inline_read_summary): Rename to ... + (ipa_fn_summary_read): ... this one. + (inline_write_summary): Rename to ... + (ipa_fn_summary_write): ... this one. + (inline_free_summary): Rename to ... + (ipa_free_fn_summary): ... this one. + (pass_data_local_fn_summary, pass_local_fn_summary, + make_pass_local_fn_summary, pass_data_ipa_free_fn_summary, + pass_ipa_free_fn_summary, make_pass_ipa_free_fn_summary, + pass_data_ipa_fn_summary, pass_ipa_fn_summary, + make_pass_ipa_fn_summary): New. + * ipa-fnsummary.h (inline_generate_summary, inline_read_summary, + inline_write_summary, inline_free_summary): Remove. + (ipa_free_fn_summary) : New. + * ipa-inline.c (ipa_inline): Update. + (pass_ipa_inline): Do not generate summaries. + * ipa.c (pass_data_ipa_free_fn_summary, pass_ipa_free_fn_summary): + Remove. + * passes.def: Replace pass_inline_parameters by pass_local_fn_summary + and add pass_ipa_fn_summary. + * tree-pass.h (make_pass_ipa_fn_summary, make_pass_local_fn_summary): + New. + (make_pass_inline_parameters): Remove. + 2017-05-23 Thomas Schwinge * omp-low.c (struct omp_context): Remove "default_kind" member. diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 34f8aaba128..7b4f47e6efb 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -339,7 +339,7 @@ symbol_table::process_new_functions (void) and splitting. This is redundant for functions added late. Just throw away whatever it did. */ if (!summaried_computed) - inline_free_summary (); + ipa_free_fn_summary (); } else if (ipa_fn_summaries != NULL) compute_fn_summary (node, true); diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c index 0a5abb54780..0e74fc31927 100644 --- a/gcc/ipa-fnsummary.c +++ b/gcc/ipa-fnsummary.c @@ -2504,46 +2504,6 @@ compute_fn_summary_for_current (void) return 0; } -namespace { - -const pass_data pass_data_inline_parameters = -{ - GIMPLE_PASS, /* type */ - "inline_param", /* name */ - OPTGROUP_INLINE, /* optinfo_flags */ - TV_INLINE_PARAMETERS, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0, /* todo_flags_finish */ -}; - -class pass_inline_parameters : public gimple_opt_pass -{ -public: - pass_inline_parameters (gcc::context *ctxt) - : gimple_opt_pass (pass_data_inline_parameters, ctxt) - {} - - /* opt_pass methods: */ - opt_pass * clone () { return new pass_inline_parameters (m_ctxt); } - virtual unsigned int execute (function *) - { - return compute_fn_summary_for_current (); - } - -}; // class pass_inline_parameters - -} // anon namespace - -gimple_opt_pass * -make_pass_inline_parameters (gcc::context *ctxt) -{ - return new pass_inline_parameters (ctxt); -} - - /* Estimate benefit devirtualizing indirect edge IE, provided KNOWN_VALS, KNOWN_CONTEXTS and KNOWN_AGGS. */ @@ -3207,8 +3167,8 @@ ipa_fn_summary_t::insert (struct cgraph_node *node, ipa_fn_summary *) /* Note function body size. */ -void -inline_generate_summary (void) +static void +ipa_fn_summary_generate (void) { struct cgraph_node *node; @@ -3226,7 +3186,7 @@ inline_generate_summary (void) ipa_fn_summaries->enable_insertion_hook (); ipa_register_cgraph_hooks (); - inline_free_summary (); + ipa_free_fn_summary (); FOR_EACH_DEFINED_FUNCTION (node) if (!node->alias) @@ -3358,8 +3318,8 @@ inline_read_section (struct lto_file_decl_data *file_data, const char *data, and inliner, so when ipa-cp is active, we don't need to write them twice. */ -void -inline_read_summary (void) +static void +ipa_fn_summary_read (void) { struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data (); struct lto_file_decl_data *file_data; @@ -3419,8 +3379,8 @@ write_ipa_call_summary (struct output_block *ob, struct cgraph_edge *e) Jump functions are shared among ipa-cp and inliner, so when ipa-cp is active, we don't need to write them twice. */ -void -inline_write_summary (void) +static void +ipa_fn_summary_write (void) { struct output_block *ob = create_output_block (LTO_section_ipa_fn_summary); lto_symtab_encoder_t encoder = ob->decl_state->symtab_node_encoder; @@ -3510,7 +3470,7 @@ inline_write_summary (void) /* Release inline summary. */ void -inline_free_summary (void) +ipa_free_fn_summary (void) { struct cgraph_node *node; if (!ipa_call_summaries) @@ -3525,3 +3485,131 @@ inline_free_summary (void) ipa_call_summaries = NULL; edge_predicate_pool.release (); } + +namespace { + +const pass_data pass_data_local_fn_summary = +{ + GIMPLE_PASS, /* type */ + "local-fnsummary", /* name */ + OPTGROUP_INLINE, /* optinfo_flags */ + TV_INLINE_PARAMETERS, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_local_fn_summary : public gimple_opt_pass +{ +public: + pass_local_fn_summary (gcc::context *ctxt) + : gimple_opt_pass (pass_data_local_fn_summary, ctxt) + {} + + /* opt_pass methods: */ + opt_pass * clone () { return new pass_local_fn_summary (m_ctxt); } + virtual unsigned int execute (function *) + { + return compute_fn_summary_for_current (); + } + +}; // class pass_local_fn_summary + +} // anon namespace + +gimple_opt_pass * +make_pass_local_fn_summary (gcc::context *ctxt) +{ + return new pass_local_fn_summary (ctxt); +} + + +/* Free inline summary. */ + +namespace { + +const pass_data pass_data_ipa_free_fn_summary = +{ + SIMPLE_IPA_PASS, /* type */ + "free-fnsummary", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_IPA_FREE_INLINE_SUMMARY, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + /* Early optimizations may make function unreachable. We can not + remove unreachable functions as part of the ealry opts pass because + TODOs are run before subpasses. Do it here. */ + ( TODO_remove_functions | TODO_dump_symtab ), /* todo_flags_finish */ +}; + +class pass_ipa_free_fn_summary : public simple_ipa_opt_pass +{ +public: + pass_ipa_free_fn_summary (gcc::context *ctxt) + : simple_ipa_opt_pass (pass_data_ipa_free_fn_summary, ctxt) + {} + + /* opt_pass methods: */ + virtual unsigned int execute (function *) + { + ipa_free_fn_summary (); + return 0; + } + +}; // class pass_ipa_free_fn_summary + +} // anon namespace + +simple_ipa_opt_pass * +make_pass_ipa_free_fn_summary (gcc::context *ctxt) +{ + return new pass_ipa_free_fn_summary (ctxt); +} + +namespace { + +const pass_data pass_data_ipa_fn_summary = +{ + IPA_PASS, /* type */ + "fnsummary", /* name */ + OPTGROUP_INLINE, /* optinfo_flags */ + TV_IPA_INLINING, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + ( TODO_dump_symtab ), /* todo_flags_finish */ +}; + +class pass_ipa_fn_summary : public ipa_opt_pass_d +{ +public: + pass_ipa_fn_summary (gcc::context *ctxt) + : ipa_opt_pass_d (pass_data_ipa_fn_summary, ctxt, + ipa_fn_summary_generate, /* generate_summary */ + ipa_fn_summary_write, /* write_summary */ + ipa_fn_summary_read, /* read_summary */ + NULL, /* write_optimization_summary */ + NULL, /* read_optimization_summary */ + NULL, /* stmt_fixup */ + 0, /* function_transform_todo_flags_start */ + NULL, /* function_transform */ + NULL) /* variable_transform */ + {} + + /* opt_pass methods: */ + virtual unsigned int execute (function *) { return 0; } + +}; // class pass_ipa_fn_summary + +} // anon namespace + +ipa_opt_pass_d * +make_pass_ipa_fn_summary (gcc::context *ctxt) +{ + return new pass_ipa_fn_summary (ctxt); +} diff --git a/gcc/ipa-fnsummary.h b/gcc/ipa-fnsummary.h index 60f7e75ff44..f50d6806e61 100644 --- a/gcc/ipa-fnsummary.h +++ b/gcc/ipa-fnsummary.h @@ -231,10 +231,7 @@ void ipa_debug_fn_summary (struct cgraph_node *); void ipa_dump_fn_summaries (FILE *f); void ipa_dump_fn_summary (FILE *f, struct cgraph_node *node); void ipa_dump_hints (FILE *f, ipa_hints); -void inline_generate_summary (void); -void inline_read_summary (void); -void inline_write_summary (void); -void inline_free_summary (void); +void ipa_free_fn_summary (void); void inline_analyze_function (struct cgraph_node *node); void estimate_ipcp_clone_size_and_time (struct cgraph_node *, vec, diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 674f8acb248..0ebe1477f6c 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -2502,7 +2502,7 @@ ipa_inline (void) ipa_dump_fn_summaries (dump_file); /* In WPA we use inline summaries for partitioning process. */ if (!flag_wpa) - inline_free_summary (); + ipa_free_fn_summary (); return remove_functions ? TODO_remove_functions : 0; } @@ -2808,9 +2808,9 @@ class pass_ipa_inline : public ipa_opt_pass_d public: pass_ipa_inline (gcc::context *ctxt) : ipa_opt_pass_d (pass_data_ipa_inline, ctxt, - inline_generate_summary, /* generate_summary */ - inline_write_summary, /* write_summary */ - inline_read_summary, /* read_summary */ + NULL, /* generate_summary */ + NULL, /* write_summary */ + NULL, /* read_summary */ NULL, /* write_optimization_summary */ NULL, /* read_optimization_summary */ NULL, /* stmt_fixup */ diff --git a/gcc/ipa.c b/gcc/ipa.c index e5b6eded690..3dc8e41a7ff 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -843,50 +843,6 @@ ipa_discover_readonly_nonaddressable_vars (void) return remove_p; } -/* Free inline summary. */ - -namespace { - -const pass_data pass_data_ipa_free_fn_summary = -{ - SIMPLE_IPA_PASS, /* type */ - "free-inline-summary", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - TV_IPA_FREE_INLINE_SUMMARY, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - /* Early optimizations may make function unreachable. We can not - remove unreachable functions as part of the ealry opts pass because - TODOs are run before subpasses. Do it here. */ - ( TODO_remove_functions | TODO_dump_symtab ), /* todo_flags_finish */ -}; - -class pass_ipa_free_fn_summary : public simple_ipa_opt_pass -{ -public: - pass_ipa_free_fn_summary (gcc::context *ctxt) - : simple_ipa_opt_pass (pass_data_ipa_free_fn_summary, ctxt) - {} - - /* opt_pass methods: */ - virtual unsigned int execute (function *) - { - inline_free_summary (); - return 0; - } - -}; // class pass_ipa_free_fn_summary - -} // anon namespace - -simple_ipa_opt_pass * -make_pass_ipa_free_fn_summary (gcc::context *ctxt) -{ - return new pass_ipa_free_fn_summary (ctxt); -} - /* Generate and emit a static constructor or destructor. WHICH must be one of 'I' (for a constructor), 'D' (for a destructor), 'P' (for chp static vars constructor) or 'B' (for chkp static bounds diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 06f4d2bd7fa..e63f2037191 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,8 @@ +2017-05-23 Jan Hubicka + + * lto.c (do_whole_program_analysis): Replace inline_free_summary + by ipa_free_fn_summary. + 2017-05-23 Martin Liska * lto-symtab.c (lto_cgraph_replace_node): Use diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index 6671d8a9622..44ddf419570 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -3129,7 +3129,7 @@ do_whole_program_analysis (void) /* Inline summaries are needed for balanced partitioning. Free them now so the memory can be used for streamer caches. */ - inline_free_summary (); + ipa_free_fn_summary (); /* AUX pointers are used by partitioning code to bookkeep number of partitions symbol is in. This is no longer needed. */ diff --git a/gcc/passes.def b/gcc/passes.def index 2b460324b24..10a18bf0751 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -75,7 +75,7 @@ along with GCC; see the file COPYING3. If not see PUSH_INSERT_PASSES_WITHIN (pass_local_optimization_passes) NEXT_PASS (pass_fixup_cfg); NEXT_PASS (pass_rebuild_cgraph_edges); - NEXT_PASS (pass_inline_parameters); + NEXT_PASS (pass_local_fn_summary); NEXT_PASS (pass_early_inline); NEXT_PASS (pass_all_early_optimizations); PUSH_INSERT_PASSES_WITHIN (pass_all_early_optimizations) @@ -110,7 +110,7 @@ along with GCC; see the file COPYING3. If not see POP_INSERT_PASSES () NEXT_PASS (pass_release_ssa_names); NEXT_PASS (pass_rebuild_cgraph_edges); - NEXT_PASS (pass_inline_parameters); + NEXT_PASS (pass_local_fn_summary); POP_INSERT_PASSES () NEXT_PASS (pass_ipa_oacc); @@ -157,6 +157,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_ipa_cp); NEXT_PASS (pass_ipa_cdtor_merge); NEXT_PASS (pass_ipa_hsa); + NEXT_PASS (pass_ipa_fn_summary); NEXT_PASS (pass_ipa_inline); NEXT_PASS (pass_ipa_pure_const); NEXT_PASS (pass_ipa_reference); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9877c76a0e5..e5d4fce0dbe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-05-23 Jan Hubicka + + * gcc.dg/ipa/ctor-empty-1.c: Update template. + * gcc.dg/ipa/inline-5.c: Likewise. + * gfortran.dg/pr48636.f90: Likewise. + 2017-05-23 Nathan Sidwell * g++.dg/parse/ctor9.C: Adjust expected error. diff --git a/gcc/testsuite/gcc.dg/ipa/ctor-empty-1.c b/gcc/testsuite/gcc.dg/ipa/ctor-empty-1.c index e9e8b12a5ea..0807d494c03 100644 --- a/gcc/testsuite/gcc.dg/ipa/ctor-empty-1.c +++ b/gcc/testsuite/gcc.dg/ipa/ctor-empty-1.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -c -fdump-ipa-free-inline-summary" } */ +/* { dg-options "-O3 -c -fdump-ipa-free-fnsummary" } */ static __attribute__((constructor)) void empty_constructor() { } -/* { dg-final { scan-ipa-dump "Reclaiming functions: empty_constructor" "free-inline-summary" } } */ +/* { dg-final { scan-ipa-dump "Reclaiming functions: empty_constructor" "free-fnsummary" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/inline-5.c b/gcc/testsuite/gcc.dg/ipa/inline-5.c index 06156ce4907..559e258955e 100644 --- a/gcc/testsuite/gcc.dg/ipa/inline-5.c +++ b/gcc/testsuite/gcc.dg/ipa/inline-5.c @@ -1,6 +1,6 @@ /* Check statements that are eliminated by inlining. */ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-inline-details -fno-early-inlining -fno-partial-inlining -fno-ipa-cp" } */ +/* { dg-options "-O2 -fdump-ipa-fnsummary-details -fno-early-inlining -fno-partial-inlining -fno-ipa-cp" } */ struct a {int a,b,c,d,e;}; void t(int); @@ -34,5 +34,5 @@ accessreference (struct a *a) /* Will be eliminated by inlining */ } -/* { dg-final { scan-ipa-dump-times "Will be eliminated" 4 "inline" { xfail { { hppa*-*-* } && { ! lp64 } } } } } */ -/* { dg-final { scan-ipa-dump-times "50. will be eliminated" 1 "inline" } } */ +/* { dg-final { scan-ipa-dump-times "Will be eliminated" 4 "fnsummary" { xfail { { hppa*-*-* } && { ! lp64 } } } } } */ +/* { dg-final { scan-ipa-dump-times "50. will be eliminated" 1 "fnsummary" } } */ diff --git a/gcc/testsuite/gfortran.dg/pr48636.f90 b/gcc/testsuite/gfortran.dg/pr48636.f90 index 926d8f3fc5a..8b16680c5b6 100644 --- a/gcc/testsuite/gfortran.dg/pr48636.f90 +++ b/gcc/testsuite/gfortran.dg/pr48636.f90 @@ -1,5 +1,5 @@ ! { dg-do compile } -! { dg-options "-O3 -fdump-ipa-inline-details -fno-ipa-cp" } +! { dg-options "-O3 -fdump-ipa-inline-details -fdump-ipa-fnsummary-details -fno-ipa-cp" } module foo implicit none @@ -34,5 +34,5 @@ program main end program main ! { dg-final { scan-ipa-dump "bar\[^\\n\]*inline copy in MAIN" "inline" } } -! { dg-final { scan-ipa-dump-times "phi predicate:" 3 "inline" } } -! { dg-final { scan-ipa-dump "inline hints: loop_iterations" "inline" } } +! { dg-final { scan-ipa-dump-times "phi predicate:" 3 "fnsummary" } } +! { dg-final { scan-ipa-dump "inline hints: loop_iterations" "fnsummary" } } diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index 92a3426014c..cfa4b01f81a 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -494,6 +494,7 @@ extern ipa_opt_pass_d *make_pass_ipa_whole_program_visibility (gcc::context *ctxt); extern simple_ipa_opt_pass *make_pass_ipa_increase_alignment (gcc::context *ctxt); +extern ipa_opt_pass_d *make_pass_ipa_fn_summary (gcc::context *ctxt); extern ipa_opt_pass_d *make_pass_ipa_inline (gcc::context *ctxt); extern simple_ipa_opt_pass *make_pass_ipa_free_lang_data (gcc::context *ctxt); extern simple_ipa_opt_pass *make_pass_ipa_free_fn_summary (gcc::context *ctxt); @@ -617,7 +618,7 @@ extern rtl_opt_pass *make_pass_final (gcc::context *ctxt); extern rtl_opt_pass *make_pass_rtl_seqabstr (gcc::context *ctxt); extern gimple_opt_pass *make_pass_release_ssa_names (gcc::context *ctxt); extern gimple_opt_pass *make_pass_early_inline (gcc::context *ctxt); -extern gimple_opt_pass *make_pass_inline_parameters (gcc::context *ctxt); +extern gimple_opt_pass *make_pass_local_fn_summary (gcc::context *ctxt); extern gimple_opt_pass *make_pass_update_address_taken (gcc::context *ctxt); extern gimple_opt_pass *make_pass_convert_switch (gcc::context *ctxt); extern gimple_opt_pass *make_pass_lower_vaarg (gcc::context *ctxt); -- 2.30.2