]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/89188 (ICE in pre_and_rev_post_order_compute, at cfganal.c...
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 11:42:17 +0000 (13:42 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:42:17 +0000 (13:42 +0200)
Backported from mainline
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.

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

From-SVN: r275101

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

index ff921609067ce5be5c381cc5e0b4dcc5530a283a..4f5bbd3b542e3f201a44fdef27727644cde3984b 100644 (file)
@@ -3,6 +3,12 @@
        Backported from mainline
        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.
+
        PR rtl-optimization/89195
        * combine.c (make_extraction): For MEMs, don't extract bytes outside
        of the original MEM.
index aaa2fef692bc10d038cdf28767dbdf831b97106e..afdd6d8b4008a648cb38244daa173573c2f3ec08 100644 (file)
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -574,7 +574,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
@@ -617,12 +622,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
@@ -635,7 +634,7 @@ 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.  */
index 063fbdbca9512e34e3c5794d49c7fbf374d33695..27a09c534ef865d4324ebaaa0b5bd14685cfedc4 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        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..cb0ea79
--- /dev/null
@@ -0,0 +1,13 @@
+// PR target/89188
+// { dg-do compile { target c++11 } }
+// { dg-options "-Og -flive-range-shrinkage -fnon-call-exceptions" }
+
+struct Ax {
+  int n, a[];
+};
+
+int i = 12345678;
+int main() {
+  static Ax s{456, i};
+  ((s.a[0]) ? (void)0 : (void)0);
+}