Do not merge BBs with a different EH landing pads (PR
authorMartin Liska <mliska@suse.cz>
Thu, 13 Oct 2016 10:06:35 +0000 (12:06 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 13 Oct 2016 10:06:35 +0000 (10:06 +0000)
PR tree-optimization/77943
* g++.dg/tree-ssa/pr77943.C: New test.
PR tree-optimization/77943
* tree-ssa-tail-merge.c (merge_stmts_p): Do not merge BBs with
a different EH landing pads.

From-SVN: r241090

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/pr77943.C [new file with mode: 0644]
gcc/tree-ssa-tail-merge.c

index 843d06ad06234de5f3d95674eb9efa08127e8fac..6b431037fc43e39bb7340d57207424d24f0e46e6 100644 (file)
@@ -1,3 +1,9 @@
+2016-10-13  Martin Liska  <mliska@suse.cz>
+
+       PR tree-optimization/77943
+       * tree-ssa-tail-merge.c (merge_stmts_p): Do not merge BBs with
+       a different EH landing pads.
+
 2016-10-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/77957
index e5c3e636c2ae8fb8814e5e05be1fb622fb713f54..c059a1d79d32c27f9c8d265d70edece13df32047 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-13  Martin Liska  <mliska@suse.cz>
+
+       PR tree-optimization/77943
+       * g++.dg/tree-ssa/pr77943.C: New test.
+
 2016-10-13  Andre Vehreschild  <vehre@gcc.gnu.org>
 
        PR fortran/72832
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr77943.C b/gcc/testsuite/g++.dg/tree-ssa/pr77943.C
new file mode 100644 (file)
index 0000000..ef7954a
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -std=c++11" } */
+
+void thrower[[gnu::noinline]]() {
+    throw 1;
+}
+
+inline void fatal() noexcept {thrower();}
+inline void notFatal() {thrower();}
+
+void func(bool callFatal) {
+    if (callFatal) {
+        fatal();
+    } else { 
+        notFatal();
+    }
+}
+
+int main(int argc, const char* argv[]) {
+    try {
+        bool callFatal = argc > 1;
+        func(callFatal);
+    } catch (...) {
+    }
+}
index 5e815ec582abeadfbc51e576f0c6545799a8000c..c292ee776c2b813d12f6be55fbf465510d109ca4 100644 (file)
@@ -204,6 +204,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "params.h"
 #include "tree-ssa-sccvn.h"
 #include "cfgloop.h"
+#include "tree-eh.h"
 
 /* Describes a group of bbs with the same successors.  The successor bbs are
    cached in succs, and the successor edge flags are cached in succ_flags.
@@ -1222,6 +1223,10 @@ merge_stmts_p (gimple *stmt1, gimple *stmt2)
   if (is_tm_ending (stmt1))
     return false;
 
+  /* Verify EH landing pads.  */
+  if (lookup_stmt_eh_lp_fn (cfun, stmt1) != lookup_stmt_eh_lp_fn (cfun, stmt2))
+    return false;
+
   if (is_gimple_call (stmt1)
       && gimple_call_internal_p (stmt1))
     switch (gimple_call_internal_fn (stmt1))