df-scan.c (df_scan_free_ref_vec, [...]): New macros.
authorKenneth Zadeck <zadeck@naturalbridge.com>
Mon, 30 Jun 2008 19:28:24 +0000 (19:28 +0000)
committerKenneth Zadeck <zadeck@gcc.gnu.org>
Mon, 30 Jun 2008 19:28:24 +0000 (19:28 +0000)
2008-06-30  Kenneth Zadeck <zadeck@naturalbridge.com>

* df-scan.c (df_scan_free_ref_vec, df_scan_free_mws_vec): New
macros.
        (df_scan_free_internal): Free data structures not
allocated in storage pools.
(df_mw_hardreg_chain_delete_eq_uses): Use df_scan_free_mws_vec.
(df_refs_add_to_chains): Use df_scan_free_ref_vec and
df_scan_free_mws_vec.
* dse.c (dse_step6): Free offset_map_p and offset_map_n
unconditionally.

From-SVN: r137284

gcc/ChangeLog
gcc/df-scan.c
gcc/dse.c

index ed06103f65ebb9a1c18d641e89140f0ca0085a2e..3547b54ccf2fda357e2a284ca3f31349a6fccbf9 100644 (file)
@@ -1,3 +1,15 @@
+2008-06-30  Kenneth Zadeck <zadeck@naturalbridge.com>
+
+       * df-scan.c (df_scan_free_ref_vec, df_scan_free_mws_vec): New
+       macros.
+               (df_scan_free_internal): Free data structures not
+       allocated in storage pools.
+       (df_mw_hardreg_chain_delete_eq_uses): Use df_scan_free_mws_vec.
+       (df_refs_add_to_chains): Use df_scan_free_ref_vec and 
+       df_scan_free_mws_vec.
+       * dse.c (dse_step6): Free offset_map_p and offset_map_n
+       unconditionally.
+
 2008-06-30  H.J. Lu  <hongjiu.lu@intel.com>
 
        * config/i386/i386.c (contains_aligned_value_p): Return true
index 092273faa3bfefea510b24ef35171868a32f7813..5818717651dc3225b012aea32fa0dfafb12c7b41 100644 (file)
@@ -60,6 +60,21 @@ along with GCC; see the file COPYING3.  If not see
 #define EPILOGUE_USES(REGNO)  0
 #endif
 
+/* The following two macros free the vecs that hold either the refs or
+   the mw refs.  They are a little tricky because the vec has 0
+   elements is special and is not to be freed.  */ 
+#define df_scan_free_ref_vec(V) \
+  do { \
+    if (V && *V) \
+      free (V);  \
+  } while (0)
+
+#define df_scan_free_mws_vec(V) \
+  do { \
+    if (V && *V) \
+      free (V);  \
+  } while (0)
+
 /* The bitmap_obstack is used to hold some static variables that
    should not be reset after each function is compiled.  */
 
@@ -174,11 +189,43 @@ struct df_scan_problem_data
 
 typedef struct df_scan_bb_info *df_scan_bb_info_t;
 
+
+/* Internal function to shut down the scanning problem.  */
 static void 
 df_scan_free_internal (void)
 {
   struct df_scan_problem_data *problem_data
     = (struct df_scan_problem_data *) df_scan->problem_data;
+  unsigned int i;
+  basic_block bb;
+
+  /* The vectors that hold the refs are not pool allocated because
+     they come in many sizes.  This makes them impossible to delete
+     all at once.  */
+  for (i = 0; i < DF_INSN_SIZE(); i++)
+    {
+      struct df_insn_info *insn_info = DF_INSN_UID_GET(i);
+      /* Skip the insns that have no insn_info or have been
+        deleted.  */
+      if (insn_info)
+       {
+         df_scan_free_ref_vec (insn_info->defs);
+         df_scan_free_ref_vec (insn_info->uses);
+         df_scan_free_ref_vec (insn_info->eq_uses);
+         df_scan_free_mws_vec (insn_info->mw_hardregs);
+       }
+    }
+
+  FOR_ALL_BB (bb)
+    {
+      unsigned int bb_index = bb->index;
+      struct df_scan_bb_info *bb_info = df_scan_get_bb_info (bb_index);
+      if (bb_info)
+       {
+         df_scan_free_ref_vec (bb_info->artificial_defs);
+         df_scan_free_ref_vec (bb_info->artificial_uses);
+       }
+    }
 
   free (df->def_info.refs);
   free (df->def_info.begin);
@@ -1977,7 +2024,7 @@ df_mw_hardreg_chain_delete_eq_uses (struct df_insn_info *insn_info)
 
   if (count == 0)
     {
-      free (insn_info->mw_hardregs);
+      df_scan_free_mws_vec (insn_info->mw_hardregs);
       insn_info->mw_hardregs = df_null_mw_rec;
       return 0;
     }
@@ -2515,8 +2562,7 @@ df_refs_add_to_chains (struct df_collection_rec *collection_rec,
         chain specially.  */
       if (collection_rec->def_vec)
        {
-         if (insn_rec->defs && *insn_rec->defs)
-           free (insn_rec->defs);
+         df_scan_free_ref_vec (insn_rec->defs);
          insn_rec->defs 
            = df_install_refs (bb, collection_rec->def_vec, 
                               collection_rec->next_def,
@@ -2525,8 +2571,7 @@ df_refs_add_to_chains (struct df_collection_rec *collection_rec,
        }
       if (collection_rec->use_vec)
        {
-         if (insn_rec->uses && *insn_rec->uses)
-           free (insn_rec->uses);
+         df_scan_free_ref_vec (insn_rec->uses);
          insn_rec->uses 
            = df_install_refs (bb, collection_rec->use_vec, 
                               collection_rec->next_use,
@@ -2535,8 +2580,7 @@ df_refs_add_to_chains (struct df_collection_rec *collection_rec,
        }
       if (collection_rec->eq_use_vec)
        {
-         if (insn_rec->eq_uses && *insn_rec->eq_uses)
-           free (insn_rec->eq_uses);
+         df_scan_free_ref_vec (insn_rec->eq_uses);
          insn_rec->eq_uses 
            = df_install_refs (bb, collection_rec->eq_use_vec, 
                               collection_rec->next_eq_use,
@@ -2545,8 +2589,7 @@ df_refs_add_to_chains (struct df_collection_rec *collection_rec,
        }
       if (collection_rec->mw_vec)
        {
-         if (insn_rec->mw_hardregs && *insn_rec->mw_hardregs)
-           free (insn_rec->mw_hardregs);
+         df_scan_free_mws_vec (insn_rec->mw_hardregs);
          insn_rec->mw_hardregs 
            = df_install_mws (collection_rec->mw_vec, 
                              collection_rec->next_mw);
@@ -2556,15 +2599,13 @@ df_refs_add_to_chains (struct df_collection_rec *collection_rec,
     {
       struct df_scan_bb_info *bb_info = df_scan_get_bb_info (bb->index);
 
-      if (bb_info->artificial_defs && *bb_info->artificial_defs)
-       free (bb_info->artificial_defs);
+      df_scan_free_ref_vec (bb_info->artificial_defs);
       bb_info->artificial_defs 
        = df_install_refs (bb, collection_rec->def_vec, 
                           collection_rec->next_def,
                           df->def_regs,
                           &df->def_info, false);
-      if (bb_info->artificial_uses && *bb_info->artificial_uses)
-       free (bb_info->artificial_uses);
+      df_scan_free_ref_vec (bb_info->artificial_uses);
       bb_info->artificial_uses 
        = df_install_refs (bb, collection_rec->use_vec, 
                           collection_rec->next_use,
index b65a72b90d0a5ab6cca8c9cd47179430a816a7e8..71d3462011052cc25a9809360ff449876ecca1e1 100644 (file)
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -3156,43 +3156,30 @@ dse_step6 (bool global_done)
   group_info_t group;
   basic_block bb;
   
-  if (global_done)
-    {
-      for (i = 0; VEC_iterate (group_info_t, rtx_group_vec, i, group); i++)
-       {
-         free (group->offset_map_n);
-         free (group->offset_map_p);
-         BITMAP_FREE (group->store1_n);
-         BITMAP_FREE (group->store1_p);
-         BITMAP_FREE (group->store2_n);
-         BITMAP_FREE (group->store2_p);
-         BITMAP_FREE (group->group_kill);
-       }
-
-      FOR_ALL_BB (bb)
-       {
-         bb_info_t bb_info = bb_table[bb->index];
-         BITMAP_FREE (bb_info->gen);
-         if (bb_info->kill)
-           BITMAP_FREE (bb_info->kill);
-         if (bb_info->in)
-           BITMAP_FREE (bb_info->in);
-         if (bb_info->out)
-           BITMAP_FREE (bb_info->out);
-       }
-    }
-  else
+  for (i = 0; VEC_iterate (group_info_t, rtx_group_vec, i, group); i++)
     {
-      for (i = 0; VEC_iterate (group_info_t, rtx_group_vec, i, group); i++)
-       {
-         BITMAP_FREE (group->store1_n);
-         BITMAP_FREE (group->store1_p);
-         BITMAP_FREE (group->store2_n);
-         BITMAP_FREE (group->store2_p);
-         BITMAP_FREE (group->group_kill);
-       }
+      free (group->offset_map_n);
+      free (group->offset_map_p);
+      BITMAP_FREE (group->store1_n);
+      BITMAP_FREE (group->store1_p);
+      BITMAP_FREE (group->store2_n);
+      BITMAP_FREE (group->store2_p);
+      BITMAP_FREE (group->group_kill);
     }
 
+  if (global_done)
+    FOR_ALL_BB (bb)
+      {
+       bb_info_t bb_info = bb_table[bb->index];
+       BITMAP_FREE (bb_info->gen);
+       if (bb_info->kill)
+         BITMAP_FREE (bb_info->kill);
+       if (bb_info->in)
+         BITMAP_FREE (bb_info->in);
+       if (bb_info->out)
+         BITMAP_FREE (bb_info->out);
+      }
+
   if (clear_alias_sets)
     {
       BITMAP_FREE (clear_alias_sets);
@@ -3217,7 +3204,6 @@ dse_step6 (bool global_done)
 }
 
 
-
 /* -------------------------------------------------------------------------
    DSE
    ------------------------------------------------------------------------- */