re PR rtl-optimization/88870 (ICE: Segmentation fault (in df_worklist_propagate_backw...
authorJakub Jelinek <jakub@redhat.com>
Thu, 17 Jan 2019 08:04:28 +0000 (09:04 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 17 Jan 2019 08:04:28 +0000 (09:04 +0100)
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: r268008

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

index 6b17531b5511fc87052945ee241787011aa8ff23..986a73d011825545ed1e989a9cbf119f959853f2 100644 (file)
@@ -1,3 +1,10 @@
+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-17  Kewen Lin  <linkw@gcc.gnu.org>
 
        * doc/extend.texi: Add four new prototypes for vec_ld and seven new
index ae8c478a002a8616b6fd7098fcd58bd96e58459f..7fd9c37aa445651f17de1d5959ea10230cde0efa 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);
 
@@ -201,7 +204,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 4f85b1a10efb60fe4cdc965c8e23f1d0a7bc7cac..3548e4f7eeaae7f57841a0931a4e9d4a32f6747e 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/88870
+       * gcc.dg/pr88870.c: New test.
+
 2019-01-17  Kewen Lin  <linkw@gcc.gnu.org>
 
        * gcc.target/powerpc/altivec_vld_vst_addr.c: New test.
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;
+      }
+  }
+}