PR c++/70641
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Apr 2016 20:43:10 +0000 (20:43 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Apr 2016 20:43:10 +0000 (20:43 +0000)
* ipa-pure-const.c (pass_nothrow::execute): Call maybe_clean_eh_stmt
on all recursive call stmts.  Return TODO_cleanup_cfg if any dead
eh edges have been purged.

* g++.dg/opt/pr70641.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234962 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ipa-pure-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr70641.C [new file with mode: 0644]

index 328903d..26db5fe 100644 (file)
@@ -1,5 +1,10 @@
 2016-04-13  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/70641
+       * ipa-pure-const.c (pass_nothrow::execute): Call maybe_clean_eh_stmt
+       on all recursive call stmts.  Return TODO_cleanup_cfg if any dead
+       eh edges have been purged.
+
        PR c++/70594
        * tree-sra.c (create_access_replacement,
        get_replaced_param_substitute): Set DECL_NAMELESS on repl if it
index 892bf46..3b3a419 100644 (file)
@@ -1956,10 +1956,25 @@ pass_nothrow::execute (function *)
     }
 
   node->set_nothrow_flag (true);
+
+  bool cfg_changed = false;
+  if (self_recursive_p (node))
+    FOR_EACH_BB_FN (this_block, cfun)
+      if (gimple *g = last_stmt (this_block))
+       if (is_gimple_call (g))
+         {
+           tree callee_t = gimple_call_fndecl (g);
+           if (callee_t
+               && recursive_call_p (current_function_decl, callee_t)
+               && maybe_clean_eh_stmt (g)
+               && gimple_purge_dead_eh_edges (this_block))
+             cfg_changed = true;
+         }
+
   if (dump_file)
     fprintf (dump_file, "Function found to be nothrow: %s\n",
             current_function_name ());
-  return 0;
+  return cfg_changed ? TODO_cleanup_cfg : 0;
 }
 
 } // anon namespace
index 0987349..5e047c6 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/70641
+       * g++.dg/opt/pr70641.C: New test.
+
 2016-04-13  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        PR rtl-optimization/68749
diff --git a/gcc/testsuite/g++.dg/opt/pr70641.C b/gcc/testsuite/g++.dg/opt/pr70641.C
new file mode 100644 (file)
index 0000000..99af742
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/70641
+// { dg-do compile }
+// { dg-options "-O2" }
+
+void
+foo ()
+{
+  try { foo (); }
+  catch (...) { __builtin_abort (); }
+}