From: Jakub Jelinek Date: Wed, 20 Dec 2017 19:41:38 +0000 (+0100) Subject: re PR ipa/83506 (ICE: Segmentation fault in force_nonfallthru_and_redirect) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=442db27632e461ace26b61e968dfd8e7ab085e38;p=gcc.git re PR ipa/83506 (ICE: Segmentation fault in force_nonfallthru_and_redirect) PR ipa/83506 * ipa-fnsummary.c (pass_data_ipa_free_fn_summary): Use 0 for todo_flags_finish. (pass_ipa_free_fn_summary): Add small_p private data member, initialize to false in the ctor. (pass_ipa_free_fn_summary::clone, pass_ipa_free_fn_summary::set_pass_param, pass_ipa_free_fn_summary::gate): New methods. (pass_ipa_free_fn_summary::execute): Return TODO_remove_functions | TODO_dump_symtab if small_p. * passes.def: Add true parm for the existing pass_ipa_free_fn_summary entry and add another instance of the pass with false parm after ipa-pure-const. * ipa-pure-const.c (pass_ipa_pure_const): Don't call ipa_free_fn_summary here. * gcc.dg/pr83506.c: New test. * gcc.dg/ipa/ctor-empty-1.c: Use -fdump-ipa-free-fnsummary1 instead of -fdump-ipa-free-fnsummary and scan in free-fnsummary1 instead of free-fnsummary dump. From-SVN: r255901 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 617dba91892..43c062e1edd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,21 @@ +2017-12-20 Jakub Jelinek + + PR ipa/83506 + * ipa-fnsummary.c (pass_data_ipa_free_fn_summary): Use 0 for + todo_flags_finish. + (pass_ipa_free_fn_summary): Add small_p private data member, + initialize to false in the ctor. + (pass_ipa_free_fn_summary::clone, + pass_ipa_free_fn_summary::set_pass_param, + pass_ipa_free_fn_summary::gate): New methods. + (pass_ipa_free_fn_summary::execute): Return TODO_remove_functions + | TODO_dump_symtab if small_p. + * passes.def: Add true parm for the existing pass_ipa_free_fn_summary + entry and add another instance of the pass with false parm after + ipa-pure-const. + * ipa-pure-const.c (pass_ipa_pure_const): Don't call + ipa_free_fn_summary here. + 2017-12-20 Paolo Carlini * gimplify.c (gimplify_return_expr): Remove dead error_mark_node check. @@ -3102,7 +3120,7 @@ * config/xtensa/xtensa.h (FRAME_GROWS_DOWNWARD): Set to 1 if ASAN is enabled. -2017-12-05 Richard Biener +2017-12-05 Richard Biener * timevar.def (TV_TREE_RECIP, TV_TREE_SINCOS, TV_TREE_WIDEN_MUL): Add. * tree-ssa-math-opts.c (pass_data_cse_reciprocal): Use TV_TREE_RECIP. diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c index 7881151d6be..94150312105 100644 --- a/gcc/ipa-fnsummary.c +++ b/gcc/ipa-fnsummary.c @@ -3538,26 +3538,36 @@ const pass_data pass_data_ipa_free_fn_summary = 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 */ + 0, /* 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) + : simple_ipa_opt_pass (pass_data_ipa_free_fn_summary, ctxt), + small_p (false) {} /* opt_pass methods: */ + opt_pass *clone () { return new pass_ipa_free_fn_summary (m_ctxt); } + void set_pass_param (unsigned int n, bool param) + { + gcc_assert (n == 0); + small_p = param; + } + virtual bool gate (function *) { return small_p || !flag_wpa; } virtual unsigned int execute (function *) { ipa_free_fn_summary (); - return 0; + /* Early optimizations may make function unreachable. We can not + remove unreachable functions as part of the early opts pass because + TODOs are run before subpasses. Do it here. */ + return small_p ? TODO_remove_functions | TODO_dump_symtab : 0; } +private: + bool small_p; }; // class pass_ipa_free_fn_summary } // anon namespace diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index 22f92fcd7a0..09ca3590039 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -2013,10 +2013,6 @@ execute (function *) if (has_function_state (node)) free (get_function_state (node)); funct_state_vec.release (); - - /* In WPA we use inline summaries for partitioning process. */ - if (!flag_wpa) - ipa_free_fn_summary (); return remove_p ? TODO_remove_functions : 0; } diff --git a/gcc/passes.def b/gcc/passes.def index 67adae57c6c..46078254ba8 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -144,7 +144,7 @@ along with GCC; see the file COPYING3. If not see PUSH_INSERT_PASSES_WITHIN (pass_ipa_tree_profile) NEXT_PASS (pass_feedback_split_functions); POP_INSERT_PASSES () - NEXT_PASS (pass_ipa_free_fn_summary); + NEXT_PASS (pass_ipa_free_fn_summary, true /* small_p */); NEXT_PASS (pass_ipa_increase_alignment); NEXT_PASS (pass_ipa_tm); NEXT_PASS (pass_ipa_lower_emutls); @@ -161,6 +161,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_ipa_fn_summary); NEXT_PASS (pass_ipa_inline); NEXT_PASS (pass_ipa_pure_const); + NEXT_PASS (pass_ipa_free_fn_summary, false /* small_p */); NEXT_PASS (pass_ipa_reference); /* This pass needs to be scheduled after any IP code duplication. */ NEXT_PASS (pass_ipa_single_use); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e0e2c4a75b4..f063f26c225 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-12-20 Jakub Jelinek + + PR ipa/83506 + * gcc.dg/pr83506.c: New test. + * gcc.dg/ipa/ctor-empty-1.c: Use -fdump-ipa-free-fnsummary1 instead + of -fdump-ipa-free-fnsummary and scan in free-fnsummary1 instead of + free-fnsummary dump. + 2017-12-20 Martin Sebor PR testsuite/83483 @@ -4364,7 +4372,7 @@ * g++.dg/pr82725.C: Move to ... * g++.dg/cpp0x/pr82725.C: ... here. Add c++11 target directive. -2017-10-30 Steven G. Kargl +2017-10-30 Steven G. Kargl * gfortran.dg/dtio_13.f90: Remove TODO comment and dg-error test. diff --git a/gcc/testsuite/gcc.dg/ipa/ctor-empty-1.c b/gcc/testsuite/gcc.dg/ipa/ctor-empty-1.c index 0807d494c03..264ca3f0349 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-fnsummary" } */ +/* { dg-options "-O3 -c -fdump-ipa-free-fnsummary1" } */ static __attribute__((constructor)) void empty_constructor() { } -/* { dg-final { scan-ipa-dump "Reclaiming functions: empty_constructor" "free-fnsummary" } } */ +/* { dg-final { scan-ipa-dump "Reclaiming functions: empty_constructor" "free-fnsummary1" } } */ diff --git a/gcc/testsuite/gcc.dg/pr83506.c b/gcc/testsuite/gcc.dg/pr83506.c new file mode 100644 index 00000000000..b138c9d3ae7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr83506.c @@ -0,0 +1,14 @@ +/* PR ipa/83506 */ +/* { dg-do compile { target pthread } } */ +/* { dg-options "-O1 -ftree-parallelize-loops=2 -fno-ipa-pure-const" } */ + +unsigned int +foo (unsigned int x, int y) +{ + while (y < 1) + { + x *= 3; + ++y; + } + return x; +}