aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2015-08-19 14:22:26 +0000
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2015-08-19 14:22:26 +0000
commit1a04a3b349ece269fd8d60280ba17da5d9c4952d (patch)
treefbf0d5259d8773a3cdb4750d1791d48fa4868075
parent3994684014cd678479f0220e2f5abbc018aeb064 (diff)
PR middle-end/67133
* gimple-ssa-isolate-paths.c (insert_trap_and_remove_trailing_statements): Rename to ... (insert_trap): ... this. Don't remove trailing statements; split block instead. (find_explicit_erroneous_behaviour): Don't remove all outgoing edges. * g++.dg/torture/pr67133.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227009 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/gimple-ssa-isolate-paths.c30
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr67133.C46
4 files changed, 67 insertions, 23 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bae3c94585c..450e169abfc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2015-08-19 Marek Polacek <polacek@redhat.com>
+
+ PR middle-end/67133
+ * gimple-ssa-isolate-paths.c
+ (insert_trap_and_remove_trailing_statements): Rename to ...
+ (insert_trap): ... this. Don't remove trailing statements; split
+ block instead.
+ (find_explicit_erroneous_behaviour): Don't remove all outgoing edges.
+
2015-08-19 Mikael Morin <mikael@gcc.gnu.org>
PR other/67042
diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c
index 6f84f85856b..ca2322d1346 100644
--- a/gcc/gimple-ssa-isolate-paths.c
+++ b/gcc/gimple-ssa-isolate-paths.c
@@ -66,10 +66,10 @@ check_loadstore (gimple stmt, tree op, tree, void *data)
return false;
}
-/* Insert a trap after SI and remove SI and all statements after the trap. */
+/* Insert a trap after SI and split the block after the trap. */
static void
-insert_trap_and_remove_trailing_statements (gimple_stmt_iterator *si_p, tree op)
+insert_trap (gimple_stmt_iterator *si_p, tree op)
{
/* We want the NULL pointer dereference to actually occur so that
code that wishes to catch the signal can do so.
@@ -115,18 +115,8 @@ insert_trap_and_remove_trailing_statements (gimple_stmt_iterator *si_p, tree op)
else
gsi_insert_before (si_p, seq, GSI_NEW_STMT);
- /* We must remove statements from the end of the block so that we
- never reference a released SSA_NAME. */
- basic_block bb = gimple_bb (gsi_stmt (*si_p));
- for (gimple_stmt_iterator si = gsi_last_bb (bb);
- gsi_stmt (si) != gsi_stmt (*si_p);
- si = gsi_last_bb (bb))
- {
- stmt = gsi_stmt (si);
- unlink_stmt_vdef (stmt);
- gsi_remove (&si, true);
- release_defs (stmt);
- }
+ split_block (gimple_bb (new_stmt), new_stmt);
+ *si_p = gsi_for_stmt (stmt);
}
/* BB when reached via incoming edge E will exhibit undefined behaviour
@@ -215,7 +205,7 @@ isolate_path (basic_block bb, basic_block duplicate,
update_stmt (ret);
}
else
- insert_trap_and_remove_trailing_statements (&si2, op);
+ insert_trap (&si2, op);
}
return duplicate;
@@ -422,14 +412,8 @@ find_explicit_erroneous_behaviour (void)
continue;
}
- insert_trap_and_remove_trailing_statements (&si,
- null_pointer_node);
-
- /* And finally, remove all outgoing edges from BB. */
- edge e;
- for (edge_iterator ei = ei_start (bb->succs);
- (e = ei_safe_edge (ei)); )
- remove_edge (e);
+ insert_trap (&si, null_pointer_node);
+ bb = gimple_bb (gsi_stmt (si));
/* Ignore any more operands on this statement and
continue the statement iterator (which should
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5ed17b92ecd..e04bb1bc62d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-08-19 Marek Polacek <polacek@redhat.com>
+
+ PR middle-end/67133
+ * g++.dg/torture/pr67133.C: New test.
+
2015-08-18 Bill Schmidt <wschmidt@vnet.linux.ibm.com>
* gcc.target/powerpc/altivec-35.c: New test.
diff --git a/gcc/testsuite/g++.dg/torture/pr67133.C b/gcc/testsuite/g++.dg/torture/pr67133.C
new file mode 100644
index 00000000000..0f235728bc8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr67133.C
@@ -0,0 +1,46 @@
+// { dg-do compile }
+// { dg-additional-options "-fisolate-erroneous-paths-attribute" }
+
+class A;
+struct B {
+ typedef A type;
+};
+template <typename> struct I : B {};
+class C {
+public:
+ C(char *);
+ int size();
+};
+template <typename> struct D;
+template <typename _Tp, typename = D<_Tp>> class F {
+ class G {
+ template <typename> static _Tp *__test();
+ typedef int _Del;
+
+ public:
+ typedef decltype(__test<_Del>()) type;
+ };
+
+public:
+ typename I<_Tp>::type operator*() {
+ typename G::type a = 0;
+ return *a;
+ }
+};
+class H {
+ F<A> Out;
+ H();
+};
+void fn1(void *, void *, int) __attribute__((__nonnull__));
+class A {
+ int OutBufEnd, OutBufCur;
+
+public:
+ void operator<<(C p1) {
+ int b, c = p1.size();
+ if (OutBufEnd)
+ fn1(&OutBufCur, &b, c);
+ }
+};
+char* a;
+H::H() { *Out << a; }