From 370f38e84763ca6271d7898b4900baad3810ad81 Mon Sep 17 00:00:00 2001 From: Kenneth Zadeck Date: Mon, 30 Jun 2008 19:28:24 +0000 Subject: [PATCH] df-scan.c (df_scan_free_ref_vec, [...]): New macros. 2008-06-30 Kenneth Zadeck * 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 | 12 +++++++++ gcc/df-scan.c | 67 +++++++++++++++++++++++++++++++++++++++++---------- gcc/dse.c | 56 ++++++++++++++++-------------------------- 3 files changed, 87 insertions(+), 48 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ed06103f65e..3547b54ccf2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2008-06-30 Kenneth Zadeck + + * 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 * config/i386/i386.c (contains_aligned_value_p): Return true diff --git a/gcc/df-scan.c b/gcc/df-scan.c index 092273faa3b..5818717651d 100644 --- a/gcc/df-scan.c +++ b/gcc/df-scan.c @@ -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, diff --git a/gcc/dse.c b/gcc/dse.c index b65a72b90d0..71d34620110 100644 --- 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 ------------------------------------------------------------------------- */ -- 2.30.2