2011-08-22 Dimitrios Apostolou <ji...@gmx.net>
* tree-ssa-pre.c (phi_trans_add, init_pre, fini_pre): Added a pool for phi_translate_table elements to avoid free() calls from htab_delete().
=== modified file 'gcc/tree-ssa-pre.c' --- gcc/tree-ssa-pre.c 2011-05-04 09:04:53 +0000 +++ gcc/tree-ssa-pre.c 2011-08-17 08:43:23 +0000 @@ -515,6 +515,10 @@ typedef struct expr_pred_trans_d } *expr_pred_trans_t; typedef const struct expr_pred_trans_d *const_expr_pred_trans_t; +/* Pool of memory for the above */ + +static alloc_pool phi_translate_pool; + /* Return the hash value for a phi translation table entry. */ static hashval_t @@ -571,7 +575,8 @@ static inline void phi_trans_add (pre_expr e, pre_expr v, basic_block pred) { void **slot; - expr_pred_trans_t new_pair = XNEW (struct expr_pred_trans_d); + expr_pred_trans_t new_pair + = (expr_pred_trans_t) pool_alloc (phi_translate_pool); new_pair->e = e; new_pair->pred = pred; new_pair->v = v; @@ -580,7 +585,8 @@ phi_trans_add (pre_expr e, pre_expr v, b slot = htab_find_slot_with_hash (phi_translate_table, new_pair, new_pair->hashcode, INSERT); - free (*slot); + if (*slot) + pool_free (phi_translate_pool, *slot); *slot = (void *) new_pair; } @@ -4804,8 +4810,12 @@ init_pre (bool do_fre) calculate_dominance_info (CDI_DOMINATORS); bitmap_obstack_initialize (&grand_bitmap_obstack); + phi_translate_pool = create_alloc_pool ("phi_translate_table pool", + sizeof (struct expr_pred_trans_d), + 4096); + /* NULL as free because we'll free the whole pool in the end. */ phi_translate_table = htab_create (5110, expr_pred_trans_hash, - expr_pred_trans_eq, free); + expr_pred_trans_eq, NULL); expression_to_id = htab_create (num_ssa_names * 3, pre_expr_hash, pre_expr_eq, NULL); @@ -4839,6 +4849,7 @@ fini_pre (bool do_fre) free_alloc_pool (bitmap_set_pool); free_alloc_pool (pre_expr_pool); htab_delete (phi_translate_table); + free_alloc_pool (phi_translate_pool); htab_delete (expression_to_id); VEC_free (unsigned, heap, name_to_id);