[08/14] Convert IPA CP to symbol_summary.

Message ID f3b237e96de3c4dce221ed290a8bd05083341cfc.1526551813.git.mliska@suse.cz
State New
Headers show
Series
  • Finish transition of {symbol,call}_summary.
Related show

Commit Message

Martin Liška April 20, 2018, 1:24 p.m.
gcc/ChangeLog:

2018-04-24  Martin Liska  <mliska@suse.cz>

	* 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.
---
 gcc/ipa-cp.c   |  8 ++++----
 gcc/ipa-prop.c | 58 +++++++++++++++++++++++++++++-----------------------------
 gcc/ipa-prop.h | 36 ++++++++++++++++++++++++++++--------
 3 files changed, 61 insertions(+), 41 deletions(-)

Comments

Jan Hubicka June 7, 2018, 12:46 p.m. | #1
> 

> gcc/ChangeLog:

> 

> 2018-04-24  Martin Liska  <mliska@suse.cz>

> 

> 	* 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.


I will delegate this one to Martin Jambor. it looks fine to me in general except again
I would like to use get() on places we do not create new info.

Honza
Martin Jambor June 7, 2018, 4:03 p.m. | #2
Hi,

On Thu, Jun 07 2018, Jan Hubicka wrote:
>> 

>> gcc/ChangeLog:

>> 

>> 2018-04-24  Martin Liska  <mliska@suse.cz>

>> 

>> 	* 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.

>

> I will delegate this one to Martin Jambor. it looks fine to me in general except again

> I would like to use get() on places we do not create new info.

>


I have read the whole series couple of weeks ago and think it is a step
in the right direction, certainly when it comes to IPA-CP bits, so
unless anything changed substantially, I am OK with it.

I think most of the get_creates are actually necessary in this patch, we
could probably often move ipcp_transformation_initialize to a caller,
but let's do it as a follow-up (it is not performance critical in any
way anyhow).

Martin

Patch

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index f682ee30dec..d8b04d14310 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -4969,8 +4969,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++)
@@ -5042,8 +5042,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_transformation_summary, va_gc> *ipcp_transformations;
+
+function_summary <ipcp_transformation *> *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<ipa_bit_ggc_hash_traits>::create_ggc (37);
   if (!ipa_vr_hash_table)
     ipa_vr_hash_table = hash_table<ipa_vr_ggc_hash_traits>::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<ipa_vr, va_gc> &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_transformation_summary, va_gc> *ipcp_transformations;
+/* Function summary for IPA-CP transformation.  */
+class ipcp_transformation_t
+: public function_summary<ipcp_transformation *>
+{
+public:
+  ipcp_transformation_t (symbol_table *table, bool ggc):
+    function_summary<ipcp_transformation *> (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> ())
+      ipcp_transformation_t (symtab, true);
+    return summary;
+  }
+};
+
+/* Function summary where the IPA CP transformations are actually stored.  */
+extern GTY(()) function_summary <ipcp_transformation *> *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;
 }