This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR66793
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 8 Jul 2015 13:49:37 +0200 (CEST)
- Subject: [PATCH] Fix PR66793
- Authentication-results: sourceware.org; auth=none
The following fixes path-isolation to properly split the block
if it inserts a trap after a stmt ending a BB (in this case a noreturn
stmt).
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2015-07-08 Richard Biener <rguenther@suse.de>
PR tree-optimization/66793
* gimple-ssa-isolate-paths.c (insert_trap_and_remove_trailing_statemen):
Properly split the block after stmts ending it.
* gcc.dg/torture/pr66793.c: New testcase.
Index: gcc/gimple-ssa-isolate-paths.c
===================================================================
--- gcc/gimple-ssa-isolate-paths.c (revision 225534)
+++ gcc/gimple-ssa-isolate-paths.c (working copy)
@@ -103,7 +103,14 @@ insert_trap_and_remove_trailing_statemen
if (walk_stmt_load_store_ops (stmt, (void *)op,
check_loadstore,
check_loadstore))
- gsi_insert_after (si_p, seq, GSI_NEW_STMT);
+ {
+ gsi_insert_after (si_p, seq, GSI_NEW_STMT);
+ if (stmt_ends_bb_p (stmt))
+ {
+ split_block (gimple_bb (stmt), stmt);
+ return;
+ }
+ }
else
gsi_insert_before (si_p, seq, GSI_NEW_STMT);
Index: gcc/testsuite/gcc.dg/torture/pr66793.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr66793.c (revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr66793.c (working copy)
@@ -0,0 +1,26 @@
+/* { dg-do link } */
+
+int a, b, c;
+
+struct S0
+{
+ int f1;
+} *d;
+
+void
+fn1 (struct S0 p)
+{
+ for (p.f1 = 0; p.f1 < 1; p.f1++)
+ c = a && b ? a && b : 1;
+ for (; c;)
+ ;
+}
+
+int
+main ()
+{
+ struct S0 **f = &d;
+ d = 0;
+ fn1 (**f);
+ return 0;
+}