re PR tree-optimization/90671 (ICE on valid code at -Os and above with -g enabled...
authorJakub Jelinek <jakub@redhat.com>
Fri, 31 May 2019 07:53:48 +0000 (09:53 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 31 May 2019 07:53:48 +0000 (09:53 +0200)
PR tree-optimization/90671
* tree-ssa-threadupdate.c (ssa_create_duplicates): If
template_block used to be empty on the first call, don't use
gsi_split_seq_after and gsi_insert_seq_after, but remember whole
seq with bb_seq and set it with set_bb_seq.

* gcc.dg/torture/pr90671.c: New test.

From-SVN: r271802

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr90671.c [new file with mode: 0644]
gcc/tree-ssa-threadupdate.c

index e3792c6ee8598e7f61f34264357ffa774c34f704..5283feda9d55a185eda23ea105d9cbf6806dab81 100644 (file)
@@ -1,3 +1,11 @@
+2019-05-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/90671
+       * tree-ssa-threadupdate.c (ssa_create_duplicates): If
+       template_block used to be empty on the first call, don't use
+       gsi_split_seq_after and gsi_insert_seq_after, but remember whole
+       seq with bb_seq and set it with set_bb_seq.
+
 2019-05-31  Iain Sandoe  <iain@sandoe.co.uk>
 
        * config/i386/darwin.h (ASM_OUTPUT_MAX_SKIP_ALIGN): New.
index 341dc4c4eccd26b5cbae1884b9bdeec34cb14ab2..c081448df40feaa670103784fabb1a0b11ef69b0 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/90671
+       * gcc.dg/torture/pr90671.c: New test.
+
 2019-05-31  Iain Sandoe  <iain@sandoe.co.uk>
 
        * g++.dg/cpp0x/pr84497.C: Require alias support.
diff --git a/gcc/testsuite/gcc.dg/torture/pr90671.c b/gcc/testsuite/gcc.dg/torture/pr90671.c
new file mode 100644 (file)
index 0000000..5a99b9d
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR tree-optimization/90671 */
+/* { dg-do compile } */
+/* { dg-additional-options "-w -g" } */
+
+int a;
+
+int
+main ()
+{
+  int b, c;
+  for (c = 0; c < 2; c++)
+    while (a)
+      if (b)
+       break;
+  return 0;
+}
index d631543177464db23845f60594957c441b6ccd92..a56ccfbaa8c5d676b99d93ce475428a7dc7ad4c5 100644 (file)
@@ -1142,12 +1142,25 @@ ssa_create_duplicates (struct redirection_data **slot,
       gimple_seq seq = NULL;
       if (gsi_stmt (local_info->template_last_to_copy)
          != gsi_stmt (gsi_last_bb (local_info->template_block)))
-       seq = gsi_split_seq_after (local_info->template_last_to_copy);
+       {
+         if (gsi_end_p (local_info->template_last_to_copy))
+           {
+             seq = bb_seq (local_info->template_block);
+             set_bb_seq (local_info->template_block, NULL);
+           }
+         else
+           seq = gsi_split_seq_after (local_info->template_last_to_copy);
+       }
       create_block_for_threading (local_info->template_block, rd, 0,
                                  &local_info->duplicate_blocks);
       if (seq)
-       gsi_insert_seq_after (&local_info->template_last_to_copy,
-                             seq, GSI_SAME_STMT);
+       {
+         if (gsi_end_p (local_info->template_last_to_copy))
+           set_bb_seq (local_info->template_block, seq);
+         else
+           gsi_insert_seq_after (&local_info->template_last_to_copy,
+                                 seq, GSI_SAME_STMT);
+       }
 
       /* Go ahead and wire up outgoing edges and update PHIs for the duplicate
         block.   */