OSDN Git Service

2009-10-15 Sebastian Pop <sebastian.pop@amd.com>
[pf3gnuchains/gcc-fork.git] / gcc / dce.c
index f6a10d6..a2c6973 100644 (file)
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "regs.h"
 #include "hard-reg-set.h"
 #include "flags.h"
+#include "except.h"
 #include "df.h"
 #include "cselib.h"
 #include "dce.h"
@@ -35,9 +36,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "dbgcnt.h"
 #include "tm_p.h"
 
-DEF_VEC_I(int);
-DEF_VEC_ALLOC_I(int,heap);
-
 
 /* -------------------------------------------------------------------------
    Core mark/delete routines
@@ -81,13 +79,7 @@ deletable_insn_p_1 (rtx body)
       return false;
 
     default:
-      if (volatile_refs_p (body))
-       return false;
-
-      if (flag_non_call_exceptions && may_trap_p (body))
-       return false;
-
-      return true;
+      return !volatile_refs_p (body);
     }
 }
 
@@ -101,6 +93,14 @@ 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
@@ -115,13 +115,11 @@ 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);
 
-  if (!NONJUMP_INSN_P (insn))
-    return false;
-
   body = PATTERN (insn);
   switch (GET_CODE (body))
     {
     case USE:
+    case VAR_LOCATION:
       return false;
 
     case CLOBBER:
@@ -352,8 +350,8 @@ find_call_stack_args (rtx call_insn, bool do_mark, bool fast,
          }
        for (byte = off; byte < off + INTVAL (MEM_SIZE (mem)); byte++)
          {
-           gcc_assert (!bitmap_bit_p (sp_bytes, byte - min_sp_off));
-           bitmap_set_bit (sp_bytes, byte - min_sp_off);
+           if (!bitmap_set_bit (sp_bytes, byte - min_sp_off))
+             gcc_unreachable ();
          }
       }
 
@@ -440,9 +438,8 @@ find_call_stack_args (rtx call_insn, bool do_mark, bool fast,
        {
          if (byte < min_sp_off
              || byte >= max_sp_off
-             || !bitmap_bit_p (sp_bytes, byte - min_sp_off))
+             || !bitmap_clear_bit (sp_bytes, byte - min_sp_off))
            break;
-         bitmap_clear_bit (sp_bytes, byte - min_sp_off);
        }
 
       if (!deletable_insn_p (insn, fast, NULL))
@@ -642,6 +639,9 @@ mark_reg_dependencies (rtx insn)
   struct df_link *defs;
   df_ref *use_rec;
 
+  if (DEBUG_INSN_P (insn))
+    return;
+
   for (use_rec = DF_INSN_USES (insn); *use_rec; use_rec++)
     {
       df_ref use = *use_rec;
@@ -738,9 +738,9 @@ struct rtl_opt_pass pass_ud_rtl_dce =
 {
  {
   RTL_PASS,
-  "dce",                                /* name */
-  gate_ud_dce,                        /* gate */
-  rest_of_handle_ud_dce,              /* execute */
+  "ud dce",                             /* name */
+  gate_ud_dce,                          /* gate */
+  rest_of_handle_ud_dce,                /* execute */
   NULL,                                 /* sub */
   NULL,                                 /* next */
   0,                                    /* static_pass_number */
@@ -1090,9 +1090,9 @@ run_fast_df_dce (void)
       /* If dce is able to delete something, it has to happen
         immediately.  Otherwise there will be problems handling the
         eq_notes.  */
-      enum df_changeable_flags old_flags 
-       df_clear_flags (DF_DEFER_INSN_RESCAN + DF_NO_INSN_RESCAN);
-      
+      int old_flags =
+       df_clear_flags (DF_DEFER_INSN_RESCAN + DF_NO_INSN_RESCAN);
+
       df_in_progress = true;
       rest_of_handle_fast_dce ();
       df_in_progress = false;
@@ -1123,7 +1123,7 @@ struct rtl_opt_pass pass_fast_rtl_dce =
 {
  {
   RTL_PASS,
-  "dce",                                /* name */
+  "rtl dce",                            /* name */
   gate_fast_dce,                        /* gate */
   rest_of_handle_fast_dce,              /* execute */
   NULL,                                 /* sub */