Change use to type-based pool allocator in ipa-prop.c
authorMartin Liska <mliska@suse.cz>
Mon, 1 Jun 2015 12:50:36 +0000 (14:50 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 1 Jun 2015 12:50:36 +0000 (12:50 +0000)
* ipa-cp.c (ipcp_value::add_source): Use new type-based pool allocator.
(allocate_and_init_ipcp_value): Likewise.
(ipcp_lattice::add_value): Likewise.
(merge_agg_lats_step): Likewise.
(ipcp_driver): Likewise.
* ipa-prop.c (ipa_free_all_structures_after_ipa_cp): Likewise.
(ipa_free_all_structures_after_iinln): Likewise.
* ipa-prop.h: Likewise.

From-SVN: r223971

gcc/ChangeLog
gcc/ipa-cp.c
gcc/ipa-prop.c
gcc/ipa-prop.h

index da0d4974b861b6dd954e45293fe1497591d73c90..85c274d080228f52e9c576f01fd2b65bd1fb5f52 100644 (file)
@@ -1,3 +1,14 @@
+2015-06-01  Martin Liska  <mliska@suse.cz>
+
+       * ipa-cp.c (ipcp_value::add_source): Use new type-based pool allocator.
+       (allocate_and_init_ipcp_value): Likewise.
+       (ipcp_lattice::add_value): Likewise.
+       (merge_agg_lats_step): Likewise.
+       (ipcp_driver): Likewise.
+       * ipa-prop.c (ipa_free_all_structures_after_ipa_cp): Likewise.
+       (ipa_free_all_structures_after_iinln): Likewise.
+       * ipa-prop.h: Likewise.
+
 2015-06-01  Martin Liska  <mliska@suse.cz>
 
        * ipa-inline-analysis.c (edge_set_predicate): Use new type-based pool allocator.
index 356f402fac4e23697138596775652f93b3acc9d9..9f812fa5f5d266fd82c5a2312da330ba88c4a851 100644 (file)
@@ -291,10 +291,17 @@ public:
 
 /* Allocation pools for values and their sources in ipa-cp.  */
 
-alloc_pool ipcp_cst_values_pool;
-alloc_pool ipcp_poly_ctx_values_pool;
-alloc_pool ipcp_sources_pool;
-alloc_pool ipcp_agg_lattice_pool;
+pool_allocator<ipcp_value<tree> > ipcp_cst_values_pool
+  ("IPA-CP constant values", 32);
+
+pool_allocator<ipcp_value<ipa_polymorphic_call_context> >
+  ipcp_poly_ctx_values_pool ("IPA-CP polymorphic contexts", 32);
+
+pool_allocator<ipcp_value_source<tree> > ipcp_sources_pool
+  ("IPA-CP value sources", 64);
+
+pool_allocator<ipcp_agg_lattice> ipcp_agg_lattice_pool
+  ("IPA_CP aggregate lattices", 32);
 
 /* Maximal count found in program.  */
 
@@ -1147,7 +1154,7 @@ ipcp_value<valtype>::add_source (cgraph_edge *cs, ipcp_value *src_val,
 {
   ipcp_value_source<valtype> *src;
 
-  src = new (pool_alloc (ipcp_sources_pool)) ipcp_value_source<valtype>;
+  src = new (ipcp_sources_pool.allocate ()) ipcp_value_source<valtype>;
   src->offset = offset;
   src->cs = cs;
   src->val = src_val;
@@ -1165,7 +1172,7 @@ allocate_and_init_ipcp_value (tree source)
 {
   ipcp_value<tree> *val;
 
-  val = new (pool_alloc (ipcp_cst_values_pool)) ipcp_value<tree>;
+  val = ipcp_cst_values_pool.allocate ();
   memset (val, 0, sizeof (*val));
   val->value = source;
   return val;
@@ -1179,8 +1186,8 @@ allocate_and_init_ipcp_value (ipa_polymorphic_call_context source)
 {
   ipcp_value<ipa_polymorphic_call_context> *val;
 
-  val = new (pool_alloc (ipcp_poly_ctx_values_pool))
-    ipcp_value<ipa_polymorphic_call_context>;
+  // TODO
+  val = ipcp_poly_ctx_values_pool.allocate ();
   memset (val, 0, sizeof (*val));
   val->value = source;
   return val;
@@ -1229,7 +1236,7 @@ ipcp_lattice<valtype>::add_value (valtype newval, cgraph_edge *cs,
            {
              ipcp_value_source<valtype> *src = val->sources;
              val->sources = src->next;
-             pool_free (ipcp_sources_pool, src);
+             ipcp_sources_pool.remove ((ipcp_value_source<tree>*)src);
            }
        }
 
@@ -1599,7 +1606,7 @@ merge_agg_lats_step (struct ipcp_param_lattices *dest_plats,
       if (dest_plats->aggs_count == PARAM_VALUE (PARAM_IPA_MAX_AGG_ITEMS))
        return false;
       dest_plats->aggs_count++;
-      new_al = (struct ipcp_agg_lattice *) pool_alloc (ipcp_agg_lattice_pool);
+      new_al = ipcp_agg_lattice_pool.allocate ();
       memset (new_al, 0, sizeof (*new_al));
 
       new_al->offset = offset;
@@ -4463,16 +4470,6 @@ ipcp_driver (void)
   edge_removal_hook_holder =
     symtab->add_edge_removal_hook (&ipcp_edge_removal_hook, NULL);
 
-  ipcp_cst_values_pool = create_alloc_pool ("IPA-CP constant values",
-                                           sizeof (ipcp_value<tree>), 32);
-  ipcp_poly_ctx_values_pool = create_alloc_pool
-    ("IPA-CP polymorphic contexts",
-     sizeof (ipcp_value<ipa_polymorphic_call_context>), 32);
-  ipcp_sources_pool = create_alloc_pool ("IPA-CP value sources",
-                                        sizeof (ipcp_value_source<tree>), 64);
-  ipcp_agg_lattice_pool = create_alloc_pool ("IPA_CP aggregate lattices",
-                                            sizeof (struct ipcp_agg_lattice),
-                                            32);
   if (dump_file)
     {
       fprintf (dump_file, "\nIPA structures before propagation:\n");
index 80ce6b88e2b63012b8e7f91c2b839c9d72c693ad..e90502bca5a903156639dda8d0edb96a31eb6d92 100644 (file)
@@ -3669,10 +3669,10 @@ ipa_free_all_structures_after_ipa_cp (void)
     {
       ipa_free_all_edge_args ();
       ipa_free_all_node_params ();
-      free_alloc_pool (ipcp_sources_pool);
-      free_alloc_pool (ipcp_cst_values_pool);
-      free_alloc_pool (ipcp_poly_ctx_values_pool);
-      free_alloc_pool (ipcp_agg_lattice_pool);
+      ipcp_sources_pool.release ();
+      ipcp_cst_values_pool.release ();
+      ipcp_poly_ctx_values_pool.release ();
+      ipcp_agg_lattice_pool.release ();
       ipa_unregister_cgraph_hooks ();
       ipa_refdesc_pool.release ();
     }
@@ -3687,14 +3687,10 @@ ipa_free_all_structures_after_iinln (void)
   ipa_free_all_edge_args ();
   ipa_free_all_node_params ();
   ipa_unregister_cgraph_hooks ();
-  if (ipcp_sources_pool)
-    free_alloc_pool (ipcp_sources_pool);
-  if (ipcp_cst_values_pool)
-    free_alloc_pool (ipcp_cst_values_pool);
-  if (ipcp_poly_ctx_values_pool)
-    free_alloc_pool (ipcp_poly_ctx_values_pool);
-  if (ipcp_agg_lattice_pool)
-    free_alloc_pool (ipcp_agg_lattice_pool);
+  ipcp_sources_pool.release ();
+  ipcp_cst_values_pool.release ();
+  ipcp_poly_ctx_values_pool.release ();
+  ipcp_agg_lattice_pool.release ();
   ipa_refdesc_pool.release ();
 }
 
index 0488254492acb6b5763c21c818b211a8ee16601d..e6725aa332f3a20e92f432f795f1dcab177fed1f 100644 (file)
@@ -595,10 +595,21 @@ void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node);
 void ipa_print_all_jump_functions (FILE * f);
 void ipcp_verify_propagated_values (void);
 
-extern alloc_pool ipcp_cst_values_pool;
-extern alloc_pool ipcp_poly_ctx_values_pool;
-extern alloc_pool ipcp_sources_pool;
-extern alloc_pool ipcp_agg_lattice_pool;
+template <typename value>
+class ipcp_value;
+
+extern pool_allocator<ipcp_value<tree> > ipcp_cst_values_pool;
+extern pool_allocator<ipcp_value<ipa_polymorphic_call_context> >
+  ipcp_poly_ctx_values_pool;
+
+template <typename valtype>
+class ipcp_value_source;
+
+extern pool_allocator<ipcp_value_source<tree> > ipcp_sources_pool;
+
+class ipcp_agg_lattice;
+
+extern pool_allocator<ipcp_agg_lattice> ipcp_agg_lattice_pool;
 
 /* Operation to be performed for the parameter in ipa_parm_adjustment
    below.  */