re PR ipa/83506 (ICE: Segmentation fault in force_nonfallthru_and_redirect)
authorJakub Jelinek <jakub@gcc.gnu.org>
Wed, 20 Dec 2017 19:41:38 +0000 (20:41 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 20 Dec 2017 19:41:38 +0000 (20:41 +0100)
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

gcc/ChangeLog
gcc/ipa-fnsummary.c
gcc/ipa-pure-const.c
gcc/passes.def
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ipa/ctor-empty-1.c
gcc/testsuite/gcc.dg/pr83506.c [new file with mode: 0644]

index 617dba91892c17619b1dd4d20316e59668857e75..43c062e1eddfcb7b568e9b1700d16a43e70a4631 100644 (file)
@@ -1,3 +1,21 @@
+2017-12-20  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <paolo.carlini@oracle.com>
 
        * gimplify.c (gimplify_return_expr): Remove dead error_mark_node check.
        * config/xtensa/xtensa.h (FRAME_GROWS_DOWNWARD): Set to 1 if
        ASAN is enabled.
 
-2017-12-05  Richard Biener   <rguenther@suse.de>
+2017-12-05  Richard Biener  <rguenther@suse.de>
 
        * 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.
index 7881151d6be6c6f6c0e0f49d20e2ecbd27065a60..941503121058d1c449de12e79465e7814752d06d 100644 (file)
@@ -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
index 22f92fcd7a096168864a40d4c9ac3ae133d8cc46..09ca3590039b0f0cf28739d41bc096b48aeb0622 100644 (file)
@@ -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;
 }
 
index 67adae57c6cdc664ca5f769877433e0ebb0b7bd9..46078254ba813f2c61a5a5edcdb9bb17a87e229a 100644 (file)
@@ -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);
index e0e2c4a75b4ceeaf416abe77f913c70e922bab40..f063f26c225007df6d964576eec59f069a76e6cc 100644 (file)
@@ -1,3 +1,11 @@
+2017-12-20  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <msebor@redhat.com>
 
        PR testsuite/83483
        * g++.dg/pr82725.C: Move to ...
        * g++.dg/cpp0x/pr82725.C: ... here.  Add c++11 target directive.
 
-2017-10-30  Steven G. Kargl   <kargl@gcc.gnu.org>
+2017-10-30  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        * gfortran.dg/dtio_13.f90: Remove TODO comment and dg-error test.
 
index 0807d494c034e5cdd5ff0e8fe2d5e344a99c6e20..264ca3f0349c776fc2b5cf8eca6ccaf1b199d06d 100644 (file)
@@ -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 (file)
index 0000000..b138c9d
--- /dev/null
@@ -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;
+}