]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR rtl-optimization/88870 (ICE: Segmentation fault (in df_worklist_propa...
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 11:27:33 +0000 (13:27 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:27:33 +0000 (13:27 +0200)
Backported from mainline
2019-01-17  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/88870
* dce.c (deletable_insn_p): Never delete const/pure calls that can
throw if we can't alter the cfg or delete dead exceptions.
(mark_insn): Don't call find_call_stack_args for such calls.

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

From-SVN: r275087

gcc/ChangeLog
gcc/dce.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr88870.c [new file with mode: 0644]

index 7b77ef9622db1249f4884d6ef8f4911276a4a731..273c7fc0b7729873c748f027aa36c702f74a24f1 100644 (file)
@@ -1,6 +1,13 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-01-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/88870
+       * dce.c (deletable_insn_p): Never delete const/pure calls that can
+       throw if we can't alter the cfg or delete dead exceptions.
+       (mark_insn): Don't call find_call_stack_args for such calls.
+
        2019-01-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/88568
index 0c7874d4f2aa1a2b507eecffb75d6be89500c081..aaa2fef692bc10d038cdf28767dbdf831b97106e 100644 (file)
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -108,7 +108,10 @@ deletable_insn_p (rtx_insn *insn, bool fast, bitmap arg_stores)
       /* We can delete dead const or pure calls as long as they do not
          infinite loop.  */
       && (RTL_CONST_OR_PURE_CALL_P (insn)
-         && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)))
+         && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn))
+      /* Don't delete calls that may throw if we cannot do so.  */
+      && ((cfun->can_delete_dead_exceptions && can_alter_cfg)
+         || insn_nothrow_p (insn)))
     return find_call_stack_args (as_a <rtx_call_insn *> (insn), false,
                                 fast, arg_stores);
 
@@ -200,7 +203,9 @@ mark_insn (rtx_insn *insn, bool fast)
          && !df_in_progress
          && !SIBLING_CALL_P (insn)
          && (RTL_CONST_OR_PURE_CALL_P (insn)
-             && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)))
+             && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn))
+         && ((cfun->can_delete_dead_exceptions && can_alter_cfg)
+             || insn_nothrow_p (insn)))
        find_call_stack_args (as_a <rtx_call_insn *> (insn), true, fast, NULL);
     }
 }
index 808983ea6a39cdd9f3266f081dc34a7ed6a3e202..253f7c5e8cecd34b480802827e7d0ca64909c5f3 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-01-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/88870
+       * gcc.dg/pr88870.c: New test.
+
        2019-01-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/88568
diff --git a/gcc/testsuite/gcc.dg/pr88870.c b/gcc/testsuite/gcc.dg/pr88870.c
new file mode 100644 (file)
index 0000000..3f46f32
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR rtl-optimization/88870 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fexceptions -fnon-call-exceptions -ftrapv -fno-tree-dominator-opts" } */
+
+int a, b;
+
+void
+foo (int *x)
+{
+  int c = 0;
+  {
+    int d;
+    x = &c;
+    for (;;)
+      {
+        x = &d;
+        b = 0;
+        d = c + 1;
+        b = c = 1;
+        ++a;
+      }
+  }
+}