From: Martin Liska Date: Mon, 1 Jun 2015 12:36:49 +0000 (+0200) Subject: Change use to type-based pool allocator in X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7e46899d1d2a4d9b2e7849613168c507ad0e5f3d;p=gcc.git Change use to type-based pool allocator in * var-tracking.c (variable_htab_free):Use new type-based pool allocator. (attrs_list_clear) Likewise. (attrs_list_insert) Likewise. (attrs_list_copy) Likewise. (shared_hash_unshare) Likewise. (shared_hash_destroy) Likewise. (unshare_variable) Likewise. (var_reg_delete_and_set) Likewise. (var_reg_delete) Likewise. (var_regno_delete) Likewise. (drop_overlapping_mem_locs) Likewise. (variable_union) Likewise. (insert_into_intersection) Likewise. (canonicalize_values_star) Likewise. (variable_merge_over_cur) Likewise. (dataflow_set_merge) Likewise. (remove_duplicate_values) Likewise. (variable_post_merge_new_vals) Likewise. (dataflow_set_preserve_mem_locs) Likewise. (dataflow_set_remove_mem_locs) Likewise. (variable_from_dropped) Likewise. (variable_was_changed) Likewise. (set_slot_part) Likewise. (clobber_slot_part) Likewise. (delete_slot_part) Likewise. (loc_exp_insert_dep) Likewise. (notify_dependents_of_changed_value) Likewise. (emit_notes_for_differences_1) Likewise. (vt_emit_notes) Likewise. (vt_initialize) Likewise. (vt_finalize) Likewise. From-SVN: r223947 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d23503d0c03..0fa51f71c78 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,37 @@ +2015-06-01 Martin Liska + + * var-tracking.c (variable_htab_free):Use new type-based pool allocator. + (attrs_list_clear) Likewise. + (attrs_list_insert) Likewise. + (attrs_list_copy) Likewise. + (shared_hash_unshare) Likewise. + (shared_hash_destroy) Likewise. + (unshare_variable) Likewise. + (var_reg_delete_and_set) Likewise. + (var_reg_delete) Likewise. + (var_regno_delete) Likewise. + (drop_overlapping_mem_locs) Likewise. + (variable_union) Likewise. + (insert_into_intersection) Likewise. + (canonicalize_values_star) Likewise. + (variable_merge_over_cur) Likewise. + (dataflow_set_merge) Likewise. + (remove_duplicate_values) Likewise. + (variable_post_merge_new_vals) Likewise. + (dataflow_set_preserve_mem_locs) Likewise. + (dataflow_set_remove_mem_locs) Likewise. + (variable_from_dropped) Likewise. + (variable_was_changed) Likewise. + (set_slot_part) Likewise. + (clobber_slot_part) Likewise. + (delete_slot_part) Likewise. + (loc_exp_insert_dep) Likewise. + (notify_dependents_of_changed_value) Likewise. + (emit_notes_for_differences_1) Likewise. + (vt_emit_notes) Likewise. + (vt_initialize) Likewise. + (vt_finalize) Likewise. + 2015-06-01 Martin Liska * ira-color.c (init_update_cost_records):Use new type-based pool allocator. diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 0db43584f02..0b240073bb3 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -282,6 +282,21 @@ typedef struct attrs_def /* Offset from start of DECL. */ HOST_WIDE_INT offset; + + /* Pool allocation new operator. */ + inline void *operator new (size_t) + { + return pool.allocate (); + } + + /* Delete operator utilizing pool allocation. */ + inline void operator delete (void *ptr) + { + pool.remove ((attrs_def *) ptr); + } + + /* Memory allocation pool. */ + static pool_allocator pool; } *attrs; /* Structure for chaining the locations. */ @@ -298,6 +313,21 @@ typedef struct location_chain_def /* Initialized? */ enum var_init_status init; + + /* Pool allocation new operator. */ + inline void *operator new (size_t) + { + return pool.allocate (); + } + + /* Delete operator utilizing pool allocation. */ + inline void operator delete (void *ptr) + { + pool.remove ((location_chain_def *) ptr); + } + + /* Memory allocation pool. */ + static pool_allocator pool; } *location_chain; /* A vector of loc_exp_dep holds the active dependencies of a one-part @@ -315,6 +345,21 @@ typedef struct loc_exp_dep_s /* A pointer to the pointer to this entry (head or prev's next) in the doubly-linked list. */ struct loc_exp_dep_s **pprev; + + /* Pool allocation new operator. */ + inline void *operator new (size_t) + { + return pool.allocate (); + } + + /* Delete operator utilizing pool allocation. */ + inline void operator delete (void *ptr) + { + pool.remove ((loc_exp_dep_s *) ptr); + } + + /* Memory allocation pool. */ + static pool_allocator pool; } loc_exp_dep; @@ -554,6 +599,21 @@ typedef struct shared_hash_def /* Actual hash table. */ variable_table_type *htab; + + /* Pool allocation new operator. */ + inline void *operator new (size_t) + { + return pool.allocate (); + } + + /* Delete operator utilizing pool allocation. */ + inline void operator delete (void *ptr) + { + pool.remove ((shared_hash_def *) ptr); + } + + /* Memory allocation pool. */ + static pool_allocator pool; } *shared_hash; /* Structure holding the IN or OUT set for a basic block. */ @@ -598,22 +658,28 @@ typedef struct variable_tracking_info_def } *variable_tracking_info; /* Alloc pool for struct attrs_def. */ -static alloc_pool attrs_pool; +pool_allocator attrs_def::pool ("attrs_def pool", 1024); /* Alloc pool for struct variable_def with MAX_VAR_PARTS entries. */ -static alloc_pool var_pool; + +static pool_allocator var_pool + ("variable_def pool", 64, + (MAX_VAR_PARTS - 1) * sizeof (((variable)NULL)->var_part[0])); /* Alloc pool for struct variable_def with a single var_part entry. */ -static alloc_pool valvar_pool; +static pool_allocator valvar_pool + ("small variable_def pool", 256); /* Alloc pool for struct location_chain_def. */ -static alloc_pool loc_chain_pool; +pool_allocator location_chain_def::pool + ("location_chain_def pool", 1024); /* Alloc pool for struct shared_hash_def. */ -static alloc_pool shared_hash_pool; +pool_allocator shared_hash_def::pool + ("shared_hash_def pool", 256); /* Alloc pool for struct loc_exp_dep_s for NOT_ONEPART variables. */ -static alloc_pool loc_exp_dep_pool; +pool_allocator loc_exp_dep::pool ("loc_exp_dep pool", 64); /* Changed variables, notes will be emitted for them. */ static variable_table_type *changed_variables; @@ -784,7 +850,7 @@ stack_adjust_offset_pre_post (rtx pattern, HOST_WIDE_INT *pre, *post += INTVAL (XEXP (src, 1)); else *post -= INTVAL (XEXP (src, 1)); - return; + return; } HOST_WIDE_INT res[2] = { 0, 0 }; for_each_inc_dec (pattern, stack_adjust_offset_pre_post_cb, res); @@ -1374,7 +1440,7 @@ dv_onepart_p (decl_or_value dv) } /* Return the variable pool to be used for a dv of type ONEPART. */ -static inline alloc_pool +static inline pool_allocator & onepart_pool (onepart_enum_t onepart) { return onepart ? valvar_pool : var_pool; @@ -1457,7 +1523,7 @@ variable_htab_free (void *elem) for (node = var->var_part[i].loc_chain; node; node = next) { next = node->next; - pool_free (loc_chain_pool, node); + delete node; } var->var_part[i].loc_chain = NULL; } @@ -1472,7 +1538,7 @@ variable_htab_free (void *elem) if (var->onepart == ONEPART_DEXPR) set_dv_changed (var->dv, true); } - pool_free (onepart_pool (var->onepart), var); + onepart_pool (var->onepart).remove (var); } /* Initialize the set (array) SET of attrs to empty lists. */ @@ -1496,7 +1562,7 @@ attrs_list_clear (attrs *listp) for (list = *listp; list; list = next) { next = list->next; - pool_free (attrs_pool, list); + delete list; } *listp = NULL; } @@ -1518,9 +1584,7 @@ static void attrs_list_insert (attrs *listp, decl_or_value dv, HOST_WIDE_INT offset, rtx loc) { - attrs list; - - list = (attrs) pool_alloc (attrs_pool); + attrs list = new attrs_def; list->loc = loc; list->dv = dv; list->offset = offset; @@ -1533,12 +1597,10 @@ attrs_list_insert (attrs *listp, decl_or_value dv, static void attrs_list_copy (attrs *dstp, attrs src) { - attrs n; - attrs_list_clear (dstp); for (; src; src = src->next) { - n = (attrs) pool_alloc (attrs_pool); + attrs n = new attrs_def; n->loc = src->loc; n->dv = src->dv; n->offset = src->offset; @@ -1612,7 +1674,7 @@ shared_var_p (variable var, shared_hash vars) static shared_hash shared_hash_unshare (shared_hash vars) { - shared_hash new_vars = (shared_hash) pool_alloc (shared_hash_pool); + shared_hash new_vars = new shared_hash_def; gcc_assert (vars->refcount > 1); new_vars->refcount = 1; new_vars->htab = new variable_table_type (vars->htab->elements () + 3); @@ -1640,7 +1702,7 @@ shared_hash_destroy (shared_hash vars) if (--vars->refcount == 0) { delete vars->htab; - pool_free (shared_hash_pool, vars); + delete vars; } } @@ -1738,7 +1800,7 @@ unshare_variable (dataflow_set *set, variable_def **slot, variable var, variable new_var; int i; - new_var = (variable) pool_alloc (onepart_pool (var->onepart)); + new_var = onepart_pool (var->onepart).allocate (); new_var->dv = var->dv; new_var->refcount = 1; var->refcount--; @@ -1771,7 +1833,7 @@ unshare_variable (dataflow_set *set, variable_def **slot, variable var, { location_chain new_lc; - new_lc = (location_chain) pool_alloc (loc_chain_pool); + new_lc = new location_chain_def; new_lc->next = NULL; if (node->init > initialized) new_lc->init = node->init; @@ -1936,7 +1998,7 @@ var_reg_delete_and_set (dataflow_set *set, rtx loc, bool modify, if (dv_as_opaque (node->dv) != decl || node->offset != offset) { delete_variable_part (set, node->loc, node->dv, node->offset); - pool_free (attrs_pool, node); + delete node; *nextp = next; } else @@ -1977,7 +2039,7 @@ var_reg_delete (dataflow_set *set, rtx loc, bool clobber) if (clobber || !dv_onepart_p (node->dv)) { delete_variable_part (set, node->loc, node->dv, node->offset); - pool_free (attrs_pool, node); + delete node; *nextp = next; } else @@ -1997,7 +2059,7 @@ var_regno_delete (dataflow_set *set, int regno) { next = node->next; delete_variable_part (set, node->loc, node->dv, node->offset); - pool_free (attrs_pool, node); + delete node; } *reg = NULL; } @@ -2047,7 +2109,7 @@ get_addr_from_global_cache (rtx const loc) rtx x; gcc_checking_assert (GET_CODE (loc) == VALUE); - + bool existed; rtx *slot = &global_get_addr_cache->get_or_insert (loc, &existed); if (existed) @@ -2085,14 +2147,14 @@ get_addr_from_local_cache (dataflow_set *set, rtx const loc) location_chain l; gcc_checking_assert (GET_CODE (loc) == VALUE); - + bool existed; rtx *slot = &local_get_addr_cache->get_or_insert (loc, &existed); if (existed) return *slot; x = get_addr_from_global_cache (loc); - + /* Tentative, avoiding infinite recursion. */ *slot = x; @@ -2304,7 +2366,7 @@ drop_overlapping_mem_locs (variable_def **slot, overlapping_mems *coms) if (VAR_LOC_1PAUX (var)) VAR_LOC_FROM (var) = NULL; } - pool_free (loc_chain_pool, loc); + delete loc; } if (!var->var_part[0].loc_chain) @@ -2538,7 +2600,7 @@ val_reset (dataflow_set *set, decl_or_value dv) if (var->onepart == ONEPART_VALUE) { rtx x = dv_as_value (dv); - + /* Relationships in the global cache don't change, so reset the local cache entry only. */ rtx *slot = local_get_addr_cache->get (x); @@ -2807,7 +2869,7 @@ variable_union (variable src, dataflow_set *set) goto restart_onepart_unshared; } - *nodep = nnode = (location_chain) pool_alloc (loc_chain_pool); + *nodep = nnode = new location_chain_def; nnode->loc = snode->loc; nnode->init = snode->init; if (!snode->set_src || MEM_P (snode->set_src)) @@ -2927,7 +2989,7 @@ variable_union (variable src, dataflow_set *set) location_chain new_node; /* Copy the location from SRC. */ - new_node = (location_chain) pool_alloc (loc_chain_pool); + new_node = new location_chain_def; new_node->loc = node->loc; new_node->init = node->init; if (!node->set_src || MEM_P (node->set_src)) @@ -2982,7 +3044,7 @@ variable_union (variable src, dataflow_set *set) location_chain new_node; /* Copy the location from SRC. */ - new_node = (location_chain) pool_alloc (loc_chain_pool); + new_node = new location_chain_def; new_node->loc = node->loc; new_node->init = node->init; if (!node->set_src || MEM_P (node->set_src)) @@ -3078,7 +3140,7 @@ variable_union (variable src, dataflow_set *set) { location_chain new_lc; - new_lc = (location_chain) pool_alloc (loc_chain_pool); + new_lc = new location_chain_def; new_lc->next = NULL; new_lc->init = node->init; if (!node->set_src || MEM_P (node->set_src)) @@ -3296,7 +3358,7 @@ insert_into_intersection (location_chain *nodep, rtx loc, else if (r > 0) break; - node = (location_chain) pool_alloc (loc_chain_pool); + node = new location_chain_def; node->loc = loc; node->set_src = NULL; @@ -3817,7 +3879,7 @@ canonicalize_values_star (variable_def **slot, dataflow_set *set) if (dv_as_opaque (list->dv) == dv_as_opaque (cdv)) { *listp = list->next; - pool_free (attrs_pool, list); + delete list; list = *listp; break; } @@ -3835,7 +3897,7 @@ canonicalize_values_star (variable_def **slot, dataflow_set *set) if (dv_as_opaque (list->dv) == dv_as_opaque (dv)) { *listp = list->next; - pool_free (attrs_pool, list); + delete list; list = *listp; break; } @@ -4016,7 +4078,7 @@ variable_merge_over_cur (variable s1var, struct dfset_merge *dsm) { if (node) { - dvar = (variable) pool_alloc (onepart_pool (onepart)); + dvar = onepart_pool (onepart).allocate (); dvar->dv = dv; dvar->refcount = 1; dvar->n_var_parts = 1; @@ -4152,8 +4214,7 @@ variable_merge_over_cur (variable s1var, struct dfset_merge *dsm) INSERT); if (!*slot) { - variable var = (variable) pool_alloc (onepart_pool - (ONEPART_VALUE)); + variable var = onepart_pool (ONEPART_VALUE).allocate (); var->dv = dv; var->refcount = 1; var->n_var_parts = 1; @@ -4240,7 +4301,7 @@ dataflow_set_merge (dataflow_set *dst, dataflow_set *src2) dataflow_set_init (dst); dst->stack_adjust = cur.stack_adjust; shared_hash_destroy (dst->vars); - dst->vars = (shared_hash) pool_alloc (shared_hash_pool); + dst->vars = new shared_hash_def; dst->vars->refcount = 1; dst->vars->htab = new variable_table_type (MAX (src1_elems, src2_elems)); @@ -4366,7 +4427,7 @@ remove_duplicate_values (variable var) { /* Remove duplicate value node. */ *nodep = node->next; - pool_free (loc_chain_pool, node); + delete node; continue; } else @@ -4519,7 +4580,7 @@ variable_post_merge_new_vals (variable_def **slot, dfset_post_merge *dfpm) to be added when we bring perm in. */ att = *curp; *curp = att->next; - pool_free (attrs_pool, att); + delete att; } } @@ -4779,7 +4840,7 @@ dataflow_set_preserve_mem_locs (variable_def **slot, dataflow_set *set) } } *locp = loc->next; - pool_free (loc_chain_pool, loc); + delete loc; } if (!var->var_part[0].loc_chain) @@ -4851,7 +4912,7 @@ dataflow_set_remove_mem_locs (variable_def **slot, dataflow_set *set) if (VAR_LOC_1PAUX (var)) VAR_LOC_FROM (var) = NULL; } - pool_free (loc_chain_pool, loc); + delete loc; } if (!var->var_part[0].loc_chain) @@ -7302,7 +7363,7 @@ variable_from_dropped (decl_or_value dv, enum insert_option insert) gcc_checking_assert (onepart == ONEPART_VALUE || onepart == ONEPART_DEXPR); - empty_var = (variable) pool_alloc (onepart_pool (onepart)); + empty_var = onepart_pool (onepart).allocate (); empty_var->dv = dv; empty_var->refcount = 1; empty_var->n_var_parts = 0; @@ -7406,7 +7467,7 @@ variable_was_changed (variable var, dataflow_set *set) if (!empty_var) { - empty_var = (variable) pool_alloc (onepart_pool (onepart)); + empty_var = onepart_pool (onepart).allocate (); empty_var->dv = var->dv; empty_var->refcount = 1; empty_var->n_var_parts = 0; @@ -7530,7 +7591,7 @@ set_slot_part (dataflow_set *set, rtx loc, variable_def **slot, if (!var) { /* Create new variable information. */ - var = (variable) pool_alloc (onepart_pool (onepart)); + var = onepart_pool (onepart).allocate (); var->dv = dv; var->refcount = 1; var->n_var_parts = 1; @@ -7725,7 +7786,7 @@ set_slot_part (dataflow_set *set, rtx loc, variable_def **slot, set_src = node->set_src; if (var->var_part[pos].cur_loc == node->loc) var->var_part[pos].cur_loc = NULL; - pool_free (loc_chain_pool, node); + delete node; *nextp = next; break; } @@ -7737,7 +7798,7 @@ set_slot_part (dataflow_set *set, rtx loc, variable_def **slot, } /* Add the location to the beginning. */ - node = (location_chain) pool_alloc (loc_chain_pool); + node = new location_chain_def; node->loc = loc; node->init = initialized; node->set_src = set_src; @@ -7819,7 +7880,7 @@ clobber_slot_part (dataflow_set *set, rtx loc, variable_def **slot, if (dv_as_opaque (anode->dv) == dv_as_opaque (var->dv) && anode->offset == offset) { - pool_free (attrs_pool, anode); + delete anode; *anextp = anext; } else @@ -7919,7 +7980,7 @@ delete_slot_part (dataflow_set *set, rtx loc, variable_def **slot, if (pos == 0 && var->onepart && VAR_LOC_1PAUX (var)) VAR_LOC_FROM (var) = NULL; } - pool_free (loc_chain_pool, node); + delete node; *nextp = next; break; } @@ -8080,7 +8141,7 @@ loc_exp_insert_dep (variable var, rtx x, variable_table_type *vars) return; if (var->onepart == NOT_ONEPART) - led = (loc_exp_dep *) pool_alloc (loc_exp_dep_pool); + led = new loc_exp_dep; else { loc_exp_dep empty; @@ -8888,7 +8949,7 @@ notify_dependents_of_changed_value (rtx val, variable_table_type *htab, break; case NOT_ONEPART: - pool_free (loc_exp_dep_pool, led); + delete led; ivar = htab->find_with_hash (ldv, dv_htab_hash (ldv)); if (ivar) { @@ -9010,7 +9071,7 @@ emit_notes_for_differences_1 (variable_def **slot, variable_table_type *new_vars if (!empty_var) { - empty_var = (variable) pool_alloc (onepart_pool (old_var->onepart)); + empty_var = onepart_pool (old_var->onepart).allocate (); empty_var->dv = old_var->dv; empty_var->refcount = 0; empty_var->n_var_parts = 0; @@ -9451,8 +9512,6 @@ vt_emit_notes (void) if (MAY_HAVE_DEBUG_INSNS) { dropped_values = new variable_table_type (cselib_get_next_uid () * 2); - loc_exp_dep_pool = create_alloc_pool ("loc_exp_dep pool", - sizeof (loc_exp_dep), 64); } dataflow_set_init (&cur); @@ -9871,18 +9930,7 @@ vt_initialize (void) alloc_aux_for_blocks (sizeof (struct variable_tracking_info_def)); - attrs_pool = create_alloc_pool ("attrs_def pool", - sizeof (struct attrs_def), 1024); - var_pool = create_alloc_pool ("variable_def pool", - sizeof (struct variable_def) - + (MAX_VAR_PARTS - 1) - * sizeof (((variable)NULL)->var_part[0]), 64); - loc_chain_pool = create_alloc_pool ("location_chain_def pool", - sizeof (struct location_chain_def), - 1024); - shared_hash_pool = create_alloc_pool ("shared_hash_def pool", - sizeof (struct shared_hash_def), 256); - empty_shared_hash = (shared_hash) pool_alloc (shared_hash_pool); + empty_shared_hash = new shared_hash_def; empty_shared_hash->refcount = 1; empty_shared_hash->htab = new variable_table_type (1); changed_variables = new variable_table_type (10); @@ -9901,15 +9949,12 @@ vt_initialize (void) { cselib_init (CSELIB_RECORD_MEMORY | CSELIB_PRESERVE_CONSTANTS); scratch_regs = BITMAP_ALLOC (NULL); - valvar_pool = create_alloc_pool ("small variable_def pool", - sizeof (struct variable_def), 256); preserved_values.create (256); global_get_addr_cache = new hash_map; } else { scratch_regs = NULL; - valvar_pool = NULL; global_get_addr_cache = NULL; } @@ -10243,20 +10288,18 @@ vt_finalize (void) empty_shared_hash->htab = NULL; delete changed_variables; changed_variables = NULL; - free_alloc_pool (attrs_pool); - free_alloc_pool (var_pool); - free_alloc_pool (loc_chain_pool); - free_alloc_pool (shared_hash_pool); + attrs_def::pool.release (); + var_pool.release (); + location_chain_def::pool.release (); + shared_hash_def::pool.release (); if (MAY_HAVE_DEBUG_INSNS) { if (global_get_addr_cache) delete global_get_addr_cache; global_get_addr_cache = NULL; - if (loc_exp_dep_pool) - free_alloc_pool (loc_exp_dep_pool); - loc_exp_dep_pool = NULL; - free_alloc_pool (valvar_pool); + loc_exp_dep::pool.release (); + valvar_pool.release (); preserved_values.release (); cselib_finish (); BITMAP_FREE (scratch_regs);