From cb8abb1cf9f96365d7fa1f4583ab3cb845876f17 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 1 Jun 2015 14:34:31 +0200 Subject: [PATCH] Change use to type-based pool allocator in lra-lives.c. * lra-lives.c (free_live_range): Use new type-based pool allocator. (free_live_range_list) Likewise. (create_live_range) Likewise. (copy_live_range) Likewise. (lra_merge_live_ranges) Likewise. (remove_some_program_points_and_update_live_ranges) Likewise. (lra_live_ranges_init) Likewise. (lra_live_ranges_finish) Likewise. From-SVN: r223944 --- gcc/ChangeLog | 11 +++++++++++ gcc/lra-coalesce.c | 1 + gcc/lra-int.h | 15 +++++++++++++++ gcc/lra-lives.c | 35 ++++++++++------------------------- gcc/lra-spills.c | 1 + gcc/lra.c | 1 + 6 files changed, 39 insertions(+), 25 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9a2ec6c7a7d..be5ce2a69ce 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2015-06-01 Martin Liska + + * lra-lives.c (free_live_range): Use new type-based pool allocator. + (free_live_range_list) Likewise. + (create_live_range) Likewise. + (copy_live_range) Likewise. + (lra_merge_live_ranges) Likewise. + (remove_some_program_points_and_update_live_ranges) Likewise. + (lra_live_ranges_init) Likewise. + (lra_live_ranges_finish) Likewise. + 2015-06-01 Martin Liska * et-forest.c (et_new_occ): Use new type-based pool allocator. diff --git a/gcc/lra-coalesce.c b/gcc/lra-coalesce.c index 045691d5257..b38560323a3 100644 --- a/gcc/lra-coalesce.c +++ b/gcc/lra-coalesce.c @@ -84,6 +84,7 @@ along with GCC; see the file COPYING3. If not see #include "except.h" #include "timevar.h" #include "ira.h" +#include "alloc-pool.h" #include "lra-int.h" #include "df.h" diff --git a/gcc/lra-int.h b/gcc/lra-int.h index 12923ee216a..42e4a5445d5 100644 --- a/gcc/lra-int.h +++ b/gcc/lra-int.h @@ -54,6 +54,21 @@ struct lra_live_range lra_live_range_t next; /* Pointer to structures with the same start. */ lra_live_range_t start_next; + + /* 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 ((lra_live_range *) ptr); + } + + /* Memory allocation pool. */ + static pool_allocator pool; }; typedef struct lra_copy *lra_copy_t; diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c index 085411ee7d0..4dfe30f26b4 100644 --- a/gcc/lra-lives.c +++ b/gcc/lra-lives.c @@ -121,14 +121,7 @@ static sparseset unused_set, dead_set; static bitmap_head temp_bitmap; /* Pool for pseudo live ranges. */ -static alloc_pool live_range_pool; - -/* Free live range LR. */ -static void -free_live_range (lra_live_range_t lr) -{ - pool_free (live_range_pool, lr); -} +pool_allocator lra_live_range::pool ("live ranges", 100); /* Free live range list LR. */ static void @@ -139,7 +132,7 @@ free_live_range_list (lra_live_range_t lr) while (lr != NULL) { next = lr->next; - free_live_range (lr); + delete lr; lr = next; } } @@ -148,9 +141,7 @@ free_live_range_list (lra_live_range_t lr) static lra_live_range_t create_live_range (int regno, int start, int finish, lra_live_range_t next) { - lra_live_range_t p; - - p = (lra_live_range_t) pool_alloc (live_range_pool); + lra_live_range_t p = new lra_live_range; p->regno = regno; p->start = start; p->finish = finish; @@ -162,11 +153,7 @@ create_live_range (int regno, int start, int finish, lra_live_range_t next) static lra_live_range_t copy_live_range (lra_live_range_t r) { - lra_live_range_t p; - - p = (lra_live_range_t) pool_alloc (live_range_pool); - *p = *r; - return p; + return new lra_live_range (*r); } /* Copy live range list given by its head R and return the result. */ @@ -209,7 +196,7 @@ lra_merge_live_ranges (lra_live_range_t r1, lra_live_range_t r2) r1->start = r2->start; lra_live_range_t temp = r2; r2 = r2->next; - pool_free (live_range_pool, temp); + delete temp; } else { @@ -480,7 +467,7 @@ live_con_fun_n (edge e) basic_block dest = e->dest; bitmap bb_liveout = df_get_live_out (bb); bitmap dest_livein = df_get_live_in (dest); - + return bitmap_ior_and_compl_into (bb_liveout, dest_livein, &all_hard_regs_bitmap); } @@ -1024,7 +1011,7 @@ process_bb_lives (basic_block bb, int &curr_point, bool dead_insn_p) if (sparseset_bit_p (pseudos_live_through_calls, j)) check_pseudos_live_through_calls (j); } - + if (need_curr_point_incr) next_program_point (curr_point, freq); @@ -1109,7 +1096,7 @@ remove_some_program_points_and_update_live_ranges (void) } prev_r->start = r->start; prev_r->next = next_r; - free_live_range (r); + delete r; } } } @@ -1252,7 +1239,7 @@ lra_create_live_ranges_1 (bool all_p, bool dead_insn_p) } } lra_free_copies (); - + /* Under some circumstances, we can have functions without pseudo registers. For such functions, lra_live_max_point will be 0, see e.g. PR55604, and there's nothing more to do for us here. */ @@ -1380,8 +1367,6 @@ lra_clear_live_ranges (void) void lra_live_ranges_init (void) { - live_range_pool = create_alloc_pool ("live ranges", - sizeof (struct lra_live_range), 100); bitmap_initialize (&temp_bitmap, ®_obstack); initiate_live_solver (); } @@ -1392,5 +1377,5 @@ lra_live_ranges_finish (void) { finish_live_solver (); bitmap_clear (&temp_bitmap); - free_alloc_pool (live_range_pool); + lra_live_range::pool.release (); } diff --git a/gcc/lra-spills.c b/gcc/lra-spills.c index 19ece20d4fa..caece9a043b 100644 --- a/gcc/lra-spills.c +++ b/gcc/lra-spills.c @@ -98,6 +98,7 @@ along with GCC; see the file COPYING3. If not see #include "except.h" #include "timevar.h" #include "target.h" +#include "alloc-pool.h" #include "lra-int.h" #include "ira.h" #include "df.h" diff --git a/gcc/lra.c b/gcc/lra.c index 7c336366d8d..7440668d69a 100644 --- a/gcc/lra.c +++ b/gcc/lra.c @@ -149,6 +149,7 @@ along with GCC; see the file COPYING3. If not see #include "timevar.h" #include "target.h" #include "ira.h" +#include "alloc-pool.h" #include "lra-int.h" #include "df.h" -- 2.30.2