re PR middle-end/79499 (ICE in rtl_verify_bb_insns, at cfgrtl.c:2661)
authorJakub Jelinek <jakub@redhat.com>
Wed, 2 Aug 2017 07:13:25 +0000 (09:13 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 2 Aug 2017 07:13:25 +0000 (09:13 +0200)
PR middle-end/79499
* function.c (thread_prologue_and_epilogue_insns): Determine blocks
for find_many_sub_basic_blocks bitmap by looking up BLOCK_FOR_INSN
of first NONDEBUG_INSN_P in each of the split_prologue_seq and
prologue_seq sequences - if any.

* gcc.dg/pr79499.c: New test.

From-SVN: r250814

gcc/ChangeLog
gcc/function.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr79499.c [new file with mode: 0644]

index faacba284224c0aa058801117599250dda69ff2f..d9f8e3e7e8ccbff86c08085e125edd511d8f15ba 100644 (file)
@@ -1,3 +1,11 @@
+2017-08-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/79499
+       * function.c (thread_prologue_and_epilogue_insns): Determine blocks
+       for find_many_sub_basic_blocks bitmap by looking up BLOCK_FOR_INSN
+       of first NONDEBUG_INSN_P in each of the split_prologue_seq and
+       prologue_seq sequences - if any.
+
 2017-08-02  Richard Biener  <rguenther@suse.de>
 
        * tree-vect-stmts.c (vectorizable_store): Perform vector extracts
index 62e72eb2a9ff874e900e63cc6e3a50bd7b51ffa2..86f14847cfa1648aa6c03714d9bb5e0c58debb28 100644 (file)
@@ -6048,20 +6048,42 @@ thread_prologue_and_epilogue_insns (void)
 
   if (split_prologue_seq || prologue_seq)
     {
+      rtx_insn *split_prologue_insn = split_prologue_seq;
       if (split_prologue_seq)
-       insert_insn_on_edge (split_prologue_seq, orig_entry_edge);
+       {
+         while (split_prologue_insn && !NONDEBUG_INSN_P (split_prologue_insn))
+           split_prologue_insn = NEXT_INSN (split_prologue_insn);
+         insert_insn_on_edge (split_prologue_seq, orig_entry_edge);
+       }
 
+      rtx_insn *prologue_insn = prologue_seq;
       if (prologue_seq)
-       insert_insn_on_edge (prologue_seq, entry_edge);
+       {
+         while (prologue_insn && !NONDEBUG_INSN_P (prologue_insn))
+           prologue_insn = NEXT_INSN (prologue_insn);
+         insert_insn_on_edge (prologue_seq, entry_edge);
+       }
 
       commit_edge_insertions ();
 
       /* Look for basic blocks within the prologue insns.  */
-      auto_sbitmap blocks (last_basic_block_for_fn (cfun));
-      bitmap_clear (blocks);
-      bitmap_set_bit (blocks, entry_edge->dest->index);
-      bitmap_set_bit (blocks, orig_entry_edge->dest->index);
-      find_many_sub_basic_blocks (blocks);
+      if (split_prologue_insn
+         && BLOCK_FOR_INSN (split_prologue_insn) == NULL)
+       split_prologue_insn = NULL;
+      if (prologue_insn
+         && BLOCK_FOR_INSN (prologue_insn) == NULL)
+       prologue_insn = NULL;
+      if (split_prologue_insn || prologue_insn)
+       {
+         auto_sbitmap blocks (last_basic_block_for_fn (cfun));
+         bitmap_clear (blocks);
+         if (split_prologue_insn)
+           bitmap_set_bit (blocks,
+                           BLOCK_FOR_INSN (split_prologue_insn)->index);
+         if (prologue_insn)
+           bitmap_set_bit (blocks, BLOCK_FOR_INSN (prologue_insn)->index);
+         find_many_sub_basic_blocks (blocks);
+       }
     }
 
   default_rtl_profile ();
index 4e126f073f0bc4e35c4437d639fab60bf6fe7d87..41ccd0df84445370cb98514696f78ea196579d35 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/79499
+       * gcc.dg/pr79499.c: New test.
+
 2017-08-02  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/81633
diff --git a/gcc/testsuite/gcc.dg/pr79499.c b/gcc/testsuite/gcc.dg/pr79499.c
new file mode 100644 (file)
index 0000000..509549f
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR middle-end/79499 */
+/* { dg-do compile { target split_stack } } */
+/* { dg-options "-O2 -fsplit-stack -fno-omit-frame-pointer" } */
+
+struct S { struct S *a, *b; };
+
+void
+foo (struct S *x)
+{
+  do
+    x->b = x->a;
+  while (x = x->a);
+}