]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/70641 (ICE on valid code at -O1 and above on x86_64-linux-gnu...
authorJakub Jelinek <jakub@redhat.com>
Thu, 7 Jul 2016 12:41:25 +0000 (14:41 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 7 Jul 2016 12:41:25 +0000 (14:41 +0200)
Backported from mainline
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.

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

From-SVN: r238094

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

index b4a994f3263e2a36637625a6dee850d7e878faa3..f1eb6d0f14f268d8e1c1cbe1df85adb541aa04d8 100644 (file)
@@ -3,6 +3,11 @@
        Backported from mainline
        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 middle-end/70633
        * gimplify.c (gimplify_init_constructor): Clear TREE_STATIC if
        gimplification turns some element into non-constant.
index a4cdae9508b84704588d96d55e91e4837307de49..8bfc649e1488e472c90472f4e9c8dee7a8a9b793 100644 (file)
@@ -1961,10 +1961,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 8e93e0796f6f688ba92a36b747c4b838e31c0d9c..ca998a0c1782057d8a5d46a8a1654e2b108c268c 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2016-04-13  Jakub Jelinek  <jakub@redhat.com>
  
+       PR c++/70641
+       * g++.dg/opt/pr70641.C: New test.
+
        PR middle-end/70633
        * gcc.c-torture/compile/pr70633.c: New test.
 
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 (); }
+}