Message ID | alpine.LNX.2.02.1208191206430.20463@localhost.localdomain |
---|---|
State | New |
Headers | show |
On Sun, Aug 19, 2012 at 8:30 PM, Dimitrios Apostolou <jimis@gmx.net> wrote: > > > 2012-08-19 Dimitrios Apostolou <jimis@gmx.net> > > * gcc/tree-ssa-pre.c (phi_translate_pool): New static global > alloc_pool, used for allocating struct expr_pred_trans_d for > phi_translate_table. > (phi_trans_add, init_pre, fini_pre): Use it, avoids thousand of > malloc() and free() calls. > > > This avoids lots of malloc/free calls and slow iterations during numerous > htab_delete() in fini_pre(). Tested on pre C++-snapshot, will update info as > soon as a post C++ one is available. Ok, if bootstrap / testing still succeeds. Thanks, Richard. > > Thanks, > Dimitris
On Mon, Aug 20, 2012 at 09:37:39AM +0200, Richard Guenther wrote: > On Sun, Aug 19, 2012 at 8:30 PM, Dimitrios Apostolou <jimis@gmx.net> wrote: > > > > > > 2012-08-19 Dimitrios Apostolou <jimis@gmx.net> > > > > * gcc/tree-ssa-pre.c (phi_translate_pool): New static global > > alloc_pool, used for allocating struct expr_pred_trans_d for > > phi_translate_table. > > (phi_trans_add, init_pre, fini_pre): Use it, avoids thousand of > > malloc() and free() calls. > > > > > > This avoids lots of malloc/free calls and slow iterations during numerous > > htab_delete() in fini_pre(). Tested on pre C++-snapshot, will update info as > > soon as a post C++ one is available. > > Ok, if bootstrap / testing still succeeds. I'd note for all the recently posted patches from Dimitrios, the gcc/ prefix doesn't belong to the ChangeLog entry pathnames, the filenames are relative to the corresponding ChangeLog location. Jakub
On Mon, 20 Aug 2012, Jakub Jelinek wrote: > > I'd note for all the recently posted patches from Dimitrios, the gcc/ > prefix doesn't belong to the ChangeLog entry pathnames, the filenames are > relative to the corresponding ChangeLog location. > Ah sorry, it's what the mklog utility generates, it seems I got carried away over-using it. :-) Dimitris
=== modified file 'gcc/tree-ssa-pre.c' --- gcc/tree-ssa-pre.c 2012-08-17 08:03:54 +0000 +++ gcc/tree-ssa-pre.c 2012-08-18 16:43:02 +0000 @@ -486,7 +486,7 @@ static bitmap need_ab_cleanup; /* A three tuple {e, pred, v} used to cache phi translations in the phi_translate_table. */ -typedef struct expr_pred_trans_d : typed_free_remove<expr_pred_trans_d> +typedef struct expr_pred_trans_d : typed_noop_remove<expr_pred_trans_d> { /* The expression. */ pre_expr e; @@ -508,6 +508,12 @@ typedef struct expr_pred_trans_d : typed } *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. */ + inline hashval_t expr_pred_trans_d::hash (const expr_pred_trans_d *e) { @@ -561,7 +567,8 @@ static inline void phi_trans_add (pre_expr e, pre_expr v, basic_block pred) { expr_pred_trans_t *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; @@ -570,7 +577,8 @@ phi_trans_add (pre_expr e, pre_expr v, b slot = phi_translate_table.find_slot_with_hash (new_pair, new_pair->hashcode, INSERT); - free (*slot); + if (*slot) + pool_free (phi_translate_pool, *slot); *slot = new_pair; } @@ -4798,6 +4806,9 @@ 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", + sizeof (struct expr_pred_trans_d), + 512); phi_translate_table.create (5110); expression_to_id.create (num_ssa_names * 3); bitmap_set_pool = create_alloc_pool ("Bitmap sets", @@ -4832,6 +4843,7 @@ fini_pre (bool do_fre) free_alloc_pool (bitmap_set_pool); free_alloc_pool (pre_expr_pool); phi_translate_table.dispose (); + free_alloc_pool (phi_translate_pool); expression_to_id.dispose (); VEC_free (unsigned, heap, name_to_id);