From 9d3e0adc2a0e657b2aa384f1392dd2fac77a62d4 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 8 Jun 2018 14:22:58 +0200 Subject: [PATCH] Convert IPA CP to symbol_summary. 2018-06-08 Martin Liska * ipa-cp.c (ipcp_store_bits_results): Use ipcp_transformation_sum. (ipcp_store_vr_results): Likewise. * ipa-prop.c (ipcp_grow_transformations_if_necessary): Renamed to ... (ipcp_transformation_initialize): ... this. (ipa_set_node_agg_value_chain): (ipa_node_params_t::duplicate): Use ipcp_transformation_sum. (write_ipcp_transformation_info): Likewise. (read_ipcp_transformation_info): Likewise. (ipcp_update_bits): Likewise. (ipcp_update_vr): Likewise. (ipcp_transform_function): Likewise. * ipa-prop.h: Rename ipcp_transformation_summary to ipcp_transformation. (class ipcp_transformation_t): New function summary. (ipcp_get_transformation_summary): Use ipcp_transformation_sum. (ipa_get_agg_replacements_for_node): Likewise. From-SVN: r261314 --- gcc/ChangeLog | 21 ++++++++++++++++++ gcc/ipa-cp.c | 8 +++---- gcc/ipa-prop.c | 58 +++++++++++++++++++++++++------------------------- gcc/ipa-prop.h | 36 ++++++++++++++++++++++++------- 4 files changed, 82 insertions(+), 41 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9a4dda69f83..c13f24667e1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,24 @@ +2018-06-08 Martin Liska + + * ipa-cp.c (ipcp_store_bits_results): Use + ipcp_transformation_sum. + (ipcp_store_vr_results): Likewise. + * ipa-prop.c (ipcp_grow_transformations_if_necessary): Renamed + to ... + (ipcp_transformation_initialize): ... this. + (ipa_set_node_agg_value_chain): + (ipa_node_params_t::duplicate): Use ipcp_transformation_sum. + (write_ipcp_transformation_info): Likewise. + (read_ipcp_transformation_info): Likewise. + (ipcp_update_bits): Likewise. + (ipcp_update_vr): Likewise. + (ipcp_transform_function): Likewise. + * ipa-prop.h: Rename ipcp_transformation_summary to + ipcp_transformation. + (class ipcp_transformation_t): New function summary. + (ipcp_get_transformation_summary): Use ipcp_transformation_sum. + (ipa_get_agg_replacements_for_node): Likewise. + 2018-06-08 Martin Liska * ipa-pure-const.c (struct funct_state_d): Do it class instead diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 35e7436b450..4030bc30669 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -4949,8 +4949,8 @@ ipcp_store_bits_results (void) if (!found_useful_result) continue; - ipcp_grow_transformations_if_necessary (); - ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node); + ipcp_transformation_initialize (); + ipcp_transformation *ts = ipcp_transformation_sum->get_create (node); vec_safe_reserve_exact (ts->bits, count); for (unsigned i = 0; i < count; i++) @@ -5022,8 +5022,8 @@ ipcp_store_vr_results (void) if (!found_useful_result) continue; - ipcp_grow_transformations_if_necessary (); - ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node); + ipcp_transformation_initialize (); + ipcp_transformation *ts = ipcp_transformation_sum->get_create (node); vec_safe_reserve_exact (ts->m_vr, count); for (unsigned i = 0; i < count; i++) diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index c725b30c33d..daada4d55a5 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -55,8 +55,9 @@ along with GCC; see the file COPYING3. If not see /* Function summary where the parameter infos are actually stored. */ ipa_node_params_t *ipa_node_params_sum = NULL; -/* Vector of IPA-CP transformation data for each clone. */ -vec *ipcp_transformations; + +function_summary *ipcp_transformation_sum = NULL; + /* Edge summary for IPA-CP edge information. */ ipa_edge_args_sum_t *ipa_edge_args_sum; @@ -3729,19 +3730,18 @@ ipa_free_all_node_params (void) ipa_node_params_sum = NULL; } -/* Grow ipcp_transformations if necessary. Also allocate any necessary hash +/* Initialize IPA CP transformation summary and also allocate any necessary hash tables if they do not already exist. */ void -ipcp_grow_transformations_if_necessary (void) +ipcp_transformation_initialize (void) { - if (vec_safe_length (ipcp_transformations) - <= (unsigned) symtab->cgraph_max_uid) - vec_safe_grow_cleared (ipcp_transformations, symtab->cgraph_max_uid + 1); if (!ipa_bits_hash_table) ipa_bits_hash_table = hash_table::create_ggc (37); if (!ipa_vr_hash_table) ipa_vr_hash_table = hash_table::create_ggc (37); + if (ipcp_transformation_sum == NULL) + ipcp_transformation_sum = ipcp_transformation_t::create_ggc (symtab); } /* Set the aggregate replacements of NODE to be AGGVALS. */ @@ -3750,8 +3750,9 @@ void ipa_set_node_agg_value_chain (struct cgraph_node *node, struct ipa_agg_replacement_value *aggvals) { - ipcp_grow_transformations_if_necessary (); - (*ipcp_transformations)[node->uid].agg_values = aggvals; + ipcp_transformation_initialize (); + ipcp_transformation *s = ipcp_transformation_sum->get_create (node); + s->agg_values = aggvals; } /* Hook that is called by cgraph.c when an edge is removed. Adjust reference @@ -3915,15 +3916,14 @@ ipa_node_params_t::duplicate(cgraph_node *src, cgraph_node *dst, ipa_set_node_agg_value_chain (dst, new_av); } - ipcp_transformation_summary *src_trans - = ipcp_get_transformation_summary (src); + ipcp_transformation *src_trans = ipcp_get_transformation_summary (src); if (src_trans) { - ipcp_grow_transformations_if_necessary (); - src_trans = ipcp_get_transformation_summary (src); - ipcp_transformation_summary *dst_trans - = ipcp_get_transformation_summary (dst); + ipcp_transformation_initialize (); + src_trans = ipcp_transformation_sum->get_create (src); + ipcp_transformation *dst_trans + = ipcp_transformation_sum->get_create (dst); dst_trans->bits = vec_safe_copy (src_trans->bits); @@ -4565,7 +4565,7 @@ write_ipcp_transformation_info (output_block *ob, cgraph_node *node) streamer_write_bitpack (&bp); } - ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node); + ipcp_transformation *ts = ipcp_get_transformation_summary (node); if (ts && vec_safe_length (ts->m_vr) > 0) { count = ts->m_vr->length (); @@ -4640,9 +4640,8 @@ read_ipcp_transformation_info (lto_input_block *ib, cgraph_node *node, count = streamer_read_uhwi (ib); if (count > 0) { - ipcp_grow_transformations_if_necessary (); - - ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node); + ipcp_transformation_initialize (); + ipcp_transformation *ts = ipcp_transformation_sum->get_create (node); vec_safe_grow_cleared (ts->m_vr, count); for (i = 0; i < count; i++) { @@ -4663,9 +4662,8 @@ read_ipcp_transformation_info (lto_input_block *ib, cgraph_node *node, count = streamer_read_uhwi (ib); if (count > 0) { - ipcp_grow_transformations_if_necessary (); - - ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node); + ipcp_transformation_initialize (); + ipcp_transformation *ts = ipcp_transformation_sum->get_create (node); vec_safe_grow_cleared (ts->bits, count); for (i = 0; i < count; i++) @@ -4932,14 +4930,14 @@ ipcp_modif_dom_walker::before_dom_children (basic_block bb) } /* Update bits info of formal parameters as described in - ipcp_transformation_summary. */ + ipcp_transformation. */ static void ipcp_update_bits (struct cgraph_node *node) { tree parm = DECL_ARGUMENTS (node->decl); tree next_parm = parm; - ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node); + ipcp_transformation *ts = ipcp_get_transformation_summary (node); if (!ts || vec_safe_length (ts->bits) == 0) return; @@ -5024,7 +5022,7 @@ ipcp_update_bits (struct cgraph_node *node) } /* Update value range of formal parameters as described in - ipcp_transformation_summary. */ + ipcp_transformation. */ static void ipcp_update_vr (struct cgraph_node *node) @@ -5032,7 +5030,7 @@ ipcp_update_vr (struct cgraph_node *node) tree fndecl = node->decl; tree parm = DECL_ARGUMENTS (fndecl); tree next_parm = parm; - ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node); + ipcp_transformation *ts = ipcp_get_transformation_summary (node); if (!ts || vec_safe_length (ts->m_vr) == 0) return; const vec &vr = *ts->m_vr; @@ -5135,9 +5133,11 @@ ipcp_transform_function (struct cgraph_node *node) free_ipa_bb_info (bi); fbi.bb_infos.release (); free_dominance_info (CDI_DOMINATORS); - (*ipcp_transformations)[node->uid].agg_values = NULL; - (*ipcp_transformations)[node->uid].bits = NULL; - (*ipcp_transformations)[node->uid].m_vr = NULL; + + ipcp_transformation *s = ipcp_transformation_sum->get (node); + s->agg_values = NULL; + s->bits = NULL; + s->m_vr = NULL; vec_free (descriptors); diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h index 6fd31598261..55e10cf0f27 100644 --- a/gcc/ipa-prop.h +++ b/gcc/ipa-prop.h @@ -544,7 +544,7 @@ struct GTY(()) ipa_agg_replacement_value /* Structure holding information for the transformation phase of IPA-CP. */ -struct GTY(()) ipcp_transformation_summary +struct GTY(()) ipcp_transformation { /* Linked list of known aggregate values. */ ipa_agg_replacement_value *agg_values; @@ -556,7 +556,7 @@ struct GTY(()) ipcp_transformation_summary void ipa_set_node_agg_value_chain (struct cgraph_node *node, struct ipa_agg_replacement_value *aggvals); -void ipcp_grow_transformations_if_necessary (void); +void ipcp_transformation_initialize (void); /* ipa_edge_args stores information related to a callsite and particularly its arguments. It can be accessed by the IPA_EDGE_REF macro. */ @@ -649,8 +649,27 @@ extern GTY(()) ipa_node_params_t * ipa_node_params_sum; /* Call summary to store information about edges such as jump functions. */ extern GTY(()) ipa_edge_args_sum_t *ipa_edge_args_sum; -/* Vector of IPA-CP transformation data for each clone. */ -extern GTY(()) vec *ipcp_transformations; +/* Function summary for IPA-CP transformation. */ +class ipcp_transformation_t +: public function_summary +{ +public: + ipcp_transformation_t (symbol_table *table, bool ggc): + function_summary (table, ggc) {} + + ~ipcp_transformation_t () {} + + static ipcp_transformation_t *create_ggc (symbol_table *symtab) + { + ipcp_transformation_t *summary + = new (ggc_cleared_alloc ()) + ipcp_transformation_t (symtab, true); + return summary; + } +}; + +/* Function summary where the IPA CP transformations are actually stored. */ +extern GTY(()) function_summary *ipcp_transformation_sum; /* Return the associated parameter/argument info corresponding to the given node/edge. */ @@ -694,12 +713,13 @@ ipa_edge_args_info_available_for_edge_p (struct cgraph_edge *edge) return ipa_edge_args_sum->exists (edge); } -static inline ipcp_transformation_summary * +static inline ipcp_transformation * ipcp_get_transformation_summary (cgraph_node *node) { - if ((unsigned) node->uid >= vec_safe_length (ipcp_transformations)) + if (ipcp_transformation_sum == NULL) return NULL; - return &(*ipcp_transformations)[node->uid]; + + return ipcp_transformation_sum->get (node); } /* Return the aggregate replacements for NODE, if there are any. */ @@ -707,7 +727,7 @@ ipcp_get_transformation_summary (cgraph_node *node) static inline struct ipa_agg_replacement_value * ipa_get_agg_replacements_for_node (cgraph_node *node) { - ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node); + ipcp_transformation *ts = ipcp_get_transformation_summary (node); return ts ? ts->agg_values : NULL; } -- 2.30.2