re PR target/89188 (ICE in pre_and_rev_post_order_compute, at cfganal.c:1055)
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Feb 2019 16:21:36 +0000 (17:21 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 5 Feb 2019 16:21:36 +0000 (17:21 +0100)
PR target/89188
* dce.c (delete_unmarked_insns): Don't remove no-op moves if they
can throw, non-call exceptions are enabled and we can't delete
dead exceptions or alter cfg.  Set must_clean if
delete_insn_and_edges returns true, don't set it blindly for calls.
Assert that delete_unreachable_blocks is called only if can_alter_cfg.

* g++.dg/opt/pr89188.C: New test.

From-SVN: r268544

gcc/ChangeLog
gcc/dce.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr89188.C [new file with mode: 0644]

index c3340dbaf4085dce6599e1118fc98fe5e99b7e18..700e3fc1b34eb6140187d3012f3d7a7b5b5d2529 100644 (file)
@@ -1,5 +1,12 @@
 2019-02-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/89188
+       * dce.c (delete_unmarked_insns): Don't remove no-op moves if they
+       can throw, non-call exceptions are enabled and we can't delete
+       dead exceptions or alter cfg.  Set must_clean if
+       delete_insn_and_edges returns true, don't set it blindly for calls.
+       Assert that delete_unreachable_blocks is called only if can_alter_cfg.
+
        PR rtl-optimization/89195
        * combine.c (make_extraction): For MEMs, don't extract bytes outside
        of the original MEM.
index 7fd9c37aa445651f17de1d5959ea10230cde0efa..cb18e81592a381d2b96b2162f0c8ddf4f4175545 100644 (file)
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -584,7 +584,12 @@ delete_unmarked_insns (void)
          rtx turn_into_use = NULL_RTX;
 
          /* Always delete no-op moves.  */
-         if (noop_move_p (insn))
+         if (noop_move_p (insn)
+             /* Unless the no-op move can throw and we are not allowed
+                to alter cfg.  */
+             && (!cfun->can_throw_non_call_exceptions
+                 || (cfun->can_delete_dead_exceptions && can_alter_cfg)
+                 || insn_nothrow_p (insn)))
            {
              if (RTX_FRAME_RELATED_P (insn))
                turn_into_use
@@ -627,12 +632,6 @@ delete_unmarked_insns (void)
             for the destination regs in order to avoid dangling notes.  */
          remove_reg_equal_equiv_notes_for_defs (insn);
 
-         /* If a pure or const call is deleted, this may make the cfg
-            have unreachable blocks.  We rememeber this and call
-            delete_unreachable_blocks at the end.  */
-         if (CALL_P (insn))
-           must_clean = true;
-
          if (turn_into_use)
            {
              /* Don't remove frame related noop moves if they cary
@@ -645,12 +644,15 @@ delete_unmarked_insns (void)
            }
          else
            /* Now delete the insn.  */
-           delete_insn_and_edges (insn);
+           must_clean |= delete_insn_and_edges (insn);
        }
 
   /* Deleted a pure or const call.  */
   if (must_clean)
-    delete_unreachable_blocks ();
+    {
+      gcc_assert (can_alter_cfg);
+      delete_unreachable_blocks ();
+    }
 }
 
 
index b232907be17c2925ffaabcbe134baff8449ff3a8..3388fbe8efe3b7c708b928a7d0da0adbae02b2f4 100644 (file)
@@ -1,5 +1,8 @@
 2019-02-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/89188
+       * g++.dg/opt/pr89188.C: New test.
+
        PR rtl-optimization/89195
        * gcc.c-torture/execute/pr89195.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/opt/pr89188.C b/gcc/testsuite/g++.dg/opt/pr89188.C
new file mode 100644 (file)
index 0000000..80be237
--- /dev/null
@@ -0,0 +1,5 @@
+// PR target/89188
+// { dg-do compile { target c++11 } }
+// { dg-options "-Og -flive-range-shrinkage -fnon-call-exceptions" }
+
+#include "../torture/pr88861.C"