PR rtl-optimization/42461
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 Jun 2010 21:49:44 +0000 (21:49 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 Jun 2010 21:49:44 +0000 (21:49 +0000)
* dce.c (deletable_insn_p): Return true for const or pure calls again.
* except.c (insn_could_throw_p): Return false if !flag_exceptions.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160507 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 8c322d0..409e3ca 100644 (file)
@@ -1,3 +1,9 @@
+2010-06-09  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR rtl-optimization/42461
+       * dce.c (deletable_insn_p): Return true for const or pure calls again.
+       * except.c (insn_could_throw_p): Return false if !flag_exceptions.
+
 2010-06-09  Jan Hubicka  <jh@suse.cz>
 
        * bitmap.c (bitmap_and): Walk array forward.
index 38a5b30..ee18b58 100644 (file)
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -94,14 +94,6 @@ deletable_insn_p (rtx insn, bool fast, bitmap arg_stores)
   rtx body, x;
   int i;
 
-  /* Don't delete jumps, notes and the like.  */
-  if (!NONJUMP_INSN_P (insn))
-    return false;
-
-  /* Don't delete insns that can throw.  */
-  if (!insn_nothrow_p (insn))
-    return false;
-
   if (CALL_P (insn)
       /* We cannot delete calls inside of the recursive dce because
         this may cause basic blocks to be deleted and this messes up
@@ -116,6 +108,14 @@ deletable_insn_p (rtx insn, bool fast, bitmap arg_stores)
          && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)))
     return find_call_stack_args (insn, false, fast, arg_stores);
 
+  /* Don't delete jumps, notes and the like.  */
+  if (!NONJUMP_INSN_P (insn))
+    return false;
+
+  /* Don't delete insns that can throw.  */
+  if (!insn_nothrow_p (insn))
+    return false;
+
   body = PATTERN (insn);
   switch (GET_CODE (body))
     {
index cb4d805..16a0247 100644 (file)
@@ -1617,6 +1617,8 @@ make_reg_eh_region_note_nothrow_nononlocal (rtx insn)
 bool
 insn_could_throw_p (const_rtx insn)
 {
+  if (!flag_exceptions)
+    return false;
   if (CALL_P (insn))
     return true;
   if (INSN_P (insn) && cfun->can_throw_non_call_exceptions)
index d0154a9..1f4d552 100644 (file)
@@ -1,7 +1,11 @@
+2010-06-09  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.dg/pr42461.c: New test.
+
 2010-06-09  Daniel Franke  <franke.daniel@gmail.com>
 
-        PR fortran/44347
-        * gfortran.dg/selected_real_kind_1.f90: New.
+       PR fortran/44347
+       * gfortran.dg/selected_real_kind_1.f90: New.
 
 2010-06-09  Daniel Franke  <franke.daniel@gmail.com>
 
diff --git a/gcc/testsuite/gcc.dg/pr42461.c b/gcc/testsuite/gcc.dg/pr42461.c
new file mode 100644 (file)
index 0000000..9d23ad9
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR rtl-optimization/42461 */
+/* Reported by Patrick Pelissier <patrick.pelissier@gmail.com> */
+
+/* { dg-do link } */
+/* { dg-options "-O" } */
+
+extern int link_failure (int) __attribute__ ((pure));
+
+int main (void)
+{
+  if (link_failure (0) < 1)
+    __builtin_unreachable ();
+  return 0;
+}