tree-ssa-structalias.c: alloc_pool for struct equiv_class_label

2011-08-22 Thread Dimitrios Apostolou


2011-08-22  Dimitrios Apostolou  ji...@gmx.net

* tree-ssa-structalias.c (equiv_class_add)
(perform_var_substitution, free_var_substitution_info): Created a
new equiv_class_pool allocator pool for struct
equiv_class_label. Changed the pointer_equiv_class_table and
location_equiv_class_table hash tables to not iterate freeing all
elements in the end, but just free the pool.




Re: tree-ssa-structalias.c: alloc_pool for struct equiv_class_label

2011-08-22 Thread Dimitrios Apostolou

Forgot the patch...

On Mon, 22 Aug 2011, Dimitrios Apostolou wrote:


2011-08-22  Dimitrios Apostolou  ji...@gmx.net

* tree-ssa-structalias.c (equiv_class_add)
(perform_var_substitution, free_var_substitution_info): Created a
new equiv_class_pool allocator pool for struct
equiv_class_label. Changed the pointer_equiv_class_table and
location_equiv_class_table hash tables to not iterate freeing all
elements in the end, but just free the pool.


=== modified file 'gcc/tree-ssa-structalias.c'
--- gcc/tree-ssa-structalias.c  2011-04-29 10:59:33 +
+++ gcc/tree-ssa-structalias.c  2011-08-18 06:53:12 +
@@ -1899,6 +1899,9 @@ static htab_t pointer_equiv_class_table;
classes.  */
 static htab_t location_equiv_class_table;
 
+/* Pool of memory for storing the above */
+static alloc_pool equiv_class_pool;
+
 /* Hash function for a equiv_class_label_t */
 
 static hashval_t
@@ -1948,7 +1951,8 @@ equiv_class_add (htab_t table, unsigned 
 bitmap labels)
 {
   void **slot;
-  equiv_class_label_t ecl = XNEW (struct equiv_class_label);
+  equiv_class_label_t ecl
+= (equiv_class_label_t) pool_alloc (equiv_class_pool);
 
   ecl-labels = labels;
   ecl-equivalence_class = equivalence_class;
@@ -2159,10 +2163,14 @@ perform_var_substitution (constraint_gra
   struct scc_info *si = init_scc_info (size);
 
   bitmap_obstack_initialize (iteration_obstack);
+  equiv_class_pool = create_alloc_pool (equiv_class_label pool,
+   sizeof (struct equiv_class_label),
+   64);
+  /* NULL free function, we'll free the whole pool at the end of the pass. */
   pointer_equiv_class_table = htab_create (511, equiv_class_label_hash,
-  equiv_class_label_eq, free);
+  equiv_class_label_eq, NULL);
   location_equiv_class_table = htab_create (511, equiv_class_label_hash,
-   equiv_class_label_eq, free);
+   equiv_class_label_eq, NULL);
   pointer_equiv_class = 1;
   location_equiv_class = 1;
 
@@ -2269,6 +2277,7 @@ free_var_substitution_info (struct scc_i
   sbitmap_free (graph-direct_nodes);
   htab_delete (pointer_equiv_class_table);
   htab_delete (location_equiv_class_table);
+  free_alloc_pool (equiv_class_pool);
   bitmap_obstack_release (iteration_obstack);
 }
 



Re: tree-ssa-structalias.c: alloc_pool for struct equiv_class_label

2011-08-22 Thread Richard Guenther
On Mon, Aug 22, 2011 at 9:46 AM, Dimitrios Apostolou ji...@gmx.net wrote:

 2011-08-22  Dimitrios Apostolou  ji...@gmx.net

        * tree-ssa-structalias.c (equiv_class_add)
        (perform_var_substitution, free_var_substitution_info): Created a
        new equiv_class_pool allocator pool for struct
        equiv_class_label. Changed the pointer_equiv_class_table and
        location_equiv_class_table hash tables to not iterate freeing all
        elements in the end, but just free the pool.

Did you check if the hash functions have ever called free()?  If so why
not use the pool free function so that entries can get re-used?  If not,
the natural allocator would be an obstack instead.

Richard.





Re: tree-ssa-structalias.c: alloc_pool for struct equiv_class_label

2011-08-22 Thread Dimitrios Apostolou

On Mon, 22 Aug 2011, Richard Guenther wrote:


On Mon, Aug 22, 2011 at 9:46 AM, Dimitrios Apostolou ji...@gmx.net wrote:


2011-08-22  Dimitrios Apostolou  ji...@gmx.net

       * tree-ssa-structalias.c (equiv_class_add)
       (perform_var_substitution, free_var_substitution_info): Created a
       new equiv_class_pool allocator pool for struct
       equiv_class_label. Changed the pointer_equiv_class_table and
       location_equiv_class_table hash tables to not iterate freeing all
       elements in the end, but just free the pool.


Did you check if the hash functions have ever called free()?  If so why
not use the pool free function so that entries can get re-used?  If not,
the natural allocator would be an obstack instead.


I have not found any relevant call of htab_clear_slot(). I didn't consider 
obstacks at all for all these cases, thanks for telling me, I'll see where 
I can use them. As I've noted I have bootstrapped and tested all these 
changes at least on x86_64 with release-checking enabled, but I plan to 
test and measure all my changes together later, and hopefully on other 
platforms in the future.



Thanks,
Dimitris