re PR tree-optimization/58294 (ice in update_ssa_across_abnormal_edges, at tree-inlin...
authorJan Hubicka <jh@suse.cz>
Mon, 9 Sep 2013 12:09:50 +0000 (14:09 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Mon, 9 Sep 2013 12:09:50 +0000 (12:09 +0000)
PR middle-end/58294
* value-prof.c (gimple_ic): Copy also abnormal edges.
* g++.dg/torture/PR58294.C: New testcase.

From-SVN: r202389

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/PR58294.C [new file with mode: 0644]
gcc/value-prof.c

index ab2bdd9d64f9061311d3c65c6296ffbad31412a2..ceaf0e50e55c2fcab9db6e985bb53cd5637c7860 100644 (file)
@@ -1,3 +1,8 @@
+2013-09-09  Jan Hubicka  <jh@suse.cz>
+
+       PR middle-end/58294
+       * value-prof.c (gimple_ic): Copy also abnormal edges.
+
 2013-09-09  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * asan.c (asan_shadow_cst): Use gen_int_mode.
index 756611dc80c18c9f6ed7732b9ad9ec180afba8f6..51cab1b35bf05fa2c4d8421386b356827613d6fa 100644 (file)
@@ -1,3 +1,8 @@
+2013-09-09  Jan Hubicka  <jh@suse.cz>
+
+       PR middle-end/58294
+       * g++.dg/torture/PR58294.C: New testcase.
+
 2013-09-08  Jeff Law  <law@redhat.com>
 
        * gcc.c-torture/compile/pr58340.c: New test.
diff --git a/gcc/testsuite/g++.dg/torture/PR58294.C b/gcc/testsuite/g++.dg/torture/PR58294.C
new file mode 100644 (file)
index 0000000..e1fb95a
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-do compile }
+struct A {
+  virtual ~A();
+  virtual void m_fn1() { delete this; }
+  void m_fn2() { m_fn1(); }
+};
+
+struct B {
+  A *pi_;
+  B() { pi_->m_fn2(); }
+};
+struct C {
+  B pn;
+};
+void _setjmp();
+int png_decode() {
+  _setjmp();
+  C a;
+  return 0;
+}
index 3aa5c7469eeddbba174441bfe1c3aaf3972c29ce..498eb907e81e893a6aa048c5186e90a9b52d3b8a 100644 (file)
@@ -1299,6 +1299,9 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call,
   edge e_cd, e_ci, e_di, e_dj = NULL, e_ij;
   gimple_stmt_iterator gsi;
   int lp_nr, dflags;
+  edge e_eh, e;
+  edge_iterator ei;
+  gimple_stmt_iterator psi;
 
   cond_bb = gimple_bb (icall_stmt);
   gsi = gsi_for_stmt (icall_stmt);
@@ -1401,24 +1404,21 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call,
   lp_nr = lookup_stmt_eh_lp (icall_stmt);
   if (lp_nr > 0 && stmt_could_throw_p (dcall_stmt))
     {
-      edge e_eh, e;
-      edge_iterator ei;
-      gimple_stmt_iterator psi;
-
       add_stmt_to_eh_lp (dcall_stmt, lp_nr);
-      FOR_EACH_EDGE (e_eh, ei, icall_bb->succs)
-       if (e_eh->flags & EDGE_EH)
-         break;
-      e = make_edge (dcall_bb, e_eh->dest, EDGE_EH);
-      for (psi = gsi_start_phis (e_eh->dest);
-          !gsi_end_p (psi); gsi_next (&psi))
-       {
-         gimple phi = gsi_stmt (psi);
-         SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE (phi, e),
-                  PHI_ARG_DEF_FROM_EDGE (phi, e_eh));
-       }
     }
 
+  FOR_EACH_EDGE (e_eh, ei, icall_bb->succs)
+    if (e_eh->flags & (EDGE_EH | EDGE_ABNORMAL))
+      {
+       e = make_edge (dcall_bb, e_eh->dest, e_eh->flags);
+       for (psi = gsi_start_phis (e_eh->dest);
+            !gsi_end_p (psi); gsi_next (&psi))
+         {
+           gimple phi = gsi_stmt (psi);
+           SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE (phi, e),
+                    PHI_ARG_DEF_FROM_EDGE (phi, e_eh));
+         }
+       }
   return dcall_stmt;
 }