OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / regstat.c
index 9f8e41f..70ddfa4 100644 (file)
@@ -1,5 +1,5 @@
 /* Scanning of rtl for dataflow analysis.
-   Copyright (C) 2007
+   Copyright (C) 2007, 2008, 2009
    Free Software Foundation, Inc.
    Contributed by Kenneth Zadeck (zadeck@naturalbridge.com).
 
@@ -37,7 +37,6 @@ along with GCC; see the file COPYING3.  If not see
 
 
 struct regstat_n_sets_and_refs_t *regstat_n_sets_and_refs;
-struct regstat_n_sets_and_refs_t *regstat_n_sets_and_refs;
 
 /*----------------------------------------------------------------------------
    REG_N_SETS and REG_N_REFS.  
@@ -60,13 +59,29 @@ regstat_init_n_sets_and_refs (void)
   df_grow_reg_info ();
   gcc_assert (!regstat_n_sets_and_refs);
 
-  regstat_n_sets_and_refs = xmalloc (max_regno * sizeof (struct regstat_n_sets_and_refs_t));
-
-  for (i = 0; i < max_regno; i++)
-    {
-      SET_REG_N_SETS (i, DF_REG_DEF_COUNT (i));
-      SET_REG_N_REFS (i, DF_REG_USE_COUNT (i) + REG_N_SETS (i));
-    }
+  regstat_n_sets_and_refs = XNEWVEC (struct regstat_n_sets_and_refs_t, max_regno);
+
+  if (MAY_HAVE_DEBUG_INSNS)
+    for (i = 0; i < max_regno; i++)
+      {
+       int use_count;
+       df_ref use;
+
+       use_count = DF_REG_USE_COUNT (i);
+       for (use = DF_REG_USE_CHAIN (i); use; use = DF_REF_NEXT_REG (use))
+         if (DF_REF_INSN_INFO (use) && DEBUG_INSN_P (DF_REF_INSN (use)))
+           use_count--;
+
+
+       SET_REG_N_SETS (i, DF_REG_DEF_COUNT (i));
+       SET_REG_N_REFS (i, use_count + REG_N_SETS (i));
+      }
+  else
+    for (i = 0; i < max_regno; i++)
+      {
+       SET_REG_N_SETS (i, DF_REG_DEF_COUNT (i));
+       SET_REG_N_REFS (i, DF_REG_USE_COUNT (i) + REG_N_SETS (i));
+      }
   timevar_pop (TV_REG_STATS);
 
 }
@@ -108,8 +123,8 @@ regstat_bb_compute_ri (unsigned int bb_index,
 {
   basic_block bb = BASIC_BLOCK (bb_index);
   rtx insn;
-  struct df_ref **def_rec;
-  struct df_ref **use_rec;
+  df_ref *def_rec;
+  df_ref *use_rec;
   int luid = 0;
   bitmap_iterator bi;
   unsigned int regno;
@@ -126,14 +141,14 @@ regstat_bb_compute_ri (unsigned int bb_index,
      to begin processing.  */
   for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
     {
-      struct df_ref *def = *def_rec;
+      df_ref def = *def_rec;
       if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0)
        bitmap_clear_bit (live, DF_REF_REGNO (def));
     }
 
   for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++)
     {
-      struct df_ref *use = *use_rec;
+      df_ref use = *use_rec;
       if ((DF_REF_FLAGS (use) & DF_REF_AT_TOP) == 0)
        {
          regno = DF_REF_REGNO (use);
@@ -150,7 +165,7 @@ regstat_bb_compute_ri (unsigned int bb_index,
       struct df_mw_hardreg **mws_rec;
       rtx link;
  
-      if (!INSN_P (insn))
+      if (!NONDEBUG_INSN_P (insn))
        continue;
 
       /* Increment the live_length for all of the registers that
@@ -180,6 +195,7 @@ regstat_bb_compute_ri (unsigned int bb_index,
          EXECUTE_IF_SET_IN_BITMAP (live, 0, regno, bi)
            {
              REG_N_CALLS_CROSSED (regno)++;
+             REG_FREQ_CALLS_CROSSED (regno) += REG_FREQ_FROM_BB (bb);
              if (can_throw)
                REG_N_THROWING_CALLS_CROSSED (regno)++;
              
@@ -204,7 +220,7 @@ regstat_bb_compute_ri (unsigned int bb_index,
       for (mws_rec = DF_INSN_UID_MWS (uid); *mws_rec; mws_rec++)
        {
          struct df_mw_hardreg *mws = *mws_rec; 
-         if (mws->type == DF_REF_REG_DEF
+         if (DF_MWS_REG_DEF_P (mws)
            {
              bool all_dead = true;
              unsigned int r;
@@ -231,7 +247,7 @@ regstat_bb_compute_ri (unsigned int bb_index,
         clobber.  This code is for the return.  */
       for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
        {
-         struct df_ref *def = *def_rec;
+         df_ref def = *def_rec;
          if ((!CALL_P (insn))
              || (!(DF_REF_FLAGS (def) & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER))))
            {
@@ -280,7 +296,7 @@ regstat_bb_compute_ri (unsigned int bb_index,
       
       for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
        {
-         struct df_ref *use = *use_rec;
+         df_ref use = *use_rec;
          unsigned int uregno = DF_REF_REGNO (use);
 
          if (uregno >= FIRST_PSEUDO_REGISTER)
@@ -343,7 +359,7 @@ regstat_compute_ri (void)
   setjmp_crosses = BITMAP_ALLOC (&df_bitmap_obstack);
   max_regno = max_reg_num ();
   reg_info_p_size = max_regno;
-  reg_info_p = xcalloc (max_regno, sizeof (struct reg_info_t));
+  reg_info_p = XCNEWVEC (struct reg_info_t, max_regno);
 
   FOR_EACH_BB (bb)
     {
@@ -411,8 +427,8 @@ regstat_bb_compute_calls_crossed (unsigned int bb_index, bitmap live)
 {
   basic_block bb = BASIC_BLOCK (bb_index);
   rtx insn;
-  struct df_ref **def_rec;
-  struct df_ref **use_rec;
+  df_ref *def_rec;
+  df_ref *use_rec;
 
   bitmap_copy (live, df_get_live_out (bb));
 
@@ -420,14 +436,14 @@ regstat_bb_compute_calls_crossed (unsigned int bb_index, bitmap live)
      to begin processing.  */
   for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
     {
-      struct df_ref *def = *def_rec;
+      df_ref def = *def_rec;
       if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0)
        bitmap_clear_bit (live, DF_REF_REGNO (def));
     }
 
   for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++)
     {
-      struct df_ref *use = *use_rec;
+      df_ref use = *use_rec;
       if ((DF_REF_FLAGS (use) & DF_REF_AT_TOP) == 0)
        bitmap_set_bit (live, DF_REF_REGNO (use));
     }
@@ -445,14 +461,17 @@ regstat_bb_compute_calls_crossed (unsigned int bb_index, bitmap live)
        {
          bitmap_iterator bi;
          EXECUTE_IF_SET_IN_BITMAP (live, 0, regno, bi)
-           REG_N_CALLS_CROSSED (regno)++;
+           {
+             REG_N_CALLS_CROSSED (regno)++;
+             REG_FREQ_CALLS_CROSSED (regno) += REG_FREQ_FROM_BB (bb);
+           }
        }
          
       /* All of the defs except the return value are some sort of
         clobber.  This code is for the return.  */
       for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
        {
-         struct df_ref *def = *def_rec;
+         df_ref def = *def_rec;
          if ((!CALL_P (insn))
              || (!(DF_REF_FLAGS (def) & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER))))
            {
@@ -464,7 +483,7 @@ regstat_bb_compute_calls_crossed (unsigned int bb_index, bitmap live)
       
       for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
        {
-         struct df_ref *use = *use_rec;
+         df_ref use = *use_rec;
          bitmap_set_bit (live, DF_REF_REGNO (use));
        }
     }
@@ -484,7 +503,7 @@ regstat_compute_calls_crossed (void)
   timevar_push (TV_REG_STATS);
   max_regno = max_reg_num ();
   reg_info_p_size = max_regno;
-  reg_info_p = xcalloc (max_regno, sizeof (struct reg_info_t));
+  reg_info_p = XCNEWVEC (struct reg_info_t, max_regno);
 
   FOR_EACH_BB (bb)
     {