ipa-prop.c (ipa_propagate_indirect_call_infos): Remove ipcp summary.
authorJan Hubicka <hubicka@ucw.cz>
Mon, 11 Nov 2019 19:11:02 +0000 (19:11 +0000)
committerJan Hubicka <hubicka@gcc.gnu.org>
Mon, 11 Nov 2019 19:11:02 +0000 (19:11 +0000)
* ipa-prop.c (ipa_propagate_indirect_call_infos): Remove ipcp
summary.
(ipcp_transformation_t::duplicate): Break out from ...
(ipa_node_params_t::duplicate): ... here; add copying of agg
replacements.
* ipa-prop.h (ipcp_transformation): Add constructor and destructor.
(ipcp_transformation_t): Add duplicate.

From-SVN: r278062

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

index 9bb851367258e23a5d89ed1edbb1b90d587665b3..72d1e3d672df67bfc1762987badc24081a278fd9 100644 (file)
@@ -1,3 +1,13 @@
+2019-11-11  Jan Hubicka  <hubcika@ucw.cz>
+
+       * ipa-prop.c (ipa_propagate_indirect_call_infos): Remove ipcp
+       summary.
+       (ipcp_transformation_t::duplicate): Break out from ...
+       (ipa_node_params_t::duplicate): ... here; add copying of agg
+       replacements.
+       * ipa-prop.h (ipcp_transformation): Add constructor and destructor.
+       (ipcp_transformation_t): Add duplicate.
+
 2019-11-11  Janne Blomqvist  <jb@gcc.gnu.org>
 
         PR fortran/91828
index 71fbf192ffd83489acc29fa00eaae41725c8ca0f..a6c135f242bc56455901a30652ca585894a7dc2a 100644 (file)
@@ -3746,6 +3746,8 @@ ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
       if (ok)
         ipa_edge_args_sum->remove (cs);
     }
+  if (ipcp_transformation_sum)
+    ipcp_transformation_sum->remove (cs->callee);
 
   return changed;
 }
@@ -3986,27 +3988,28 @@ ipa_node_params_t::duplicate(cgraph_node *src, cgraph_node *dst,
        }
       ipa_set_node_agg_value_chain (dst, new_av);
     }
+}
 
-  ipcp_transformation *src_trans = ipcp_get_transformation_summary (src);
-
-  if (src_trans)
-    {
-      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);
+/* Duplication of ipcp transformation summaries.  */
 
-      const vec<ipa_vr, va_gc> *src_vr = src_trans->m_vr;
-      vec<ipa_vr, va_gc> *&dst_vr
-       = ipcp_get_transformation_summary (dst)->m_vr;
-      if (vec_safe_length (src_trans->m_vr) > 0)
-       {
-         vec_safe_reserve_exact (dst_vr, src_vr->length ());
-         for (unsigned i = 0; i < src_vr->length (); ++i)
-           dst_vr->quick_push ((*src_vr)[i]);
-       }
+void
+ipcp_transformation_t::duplicate(cgraph_node *, cgraph_node *dst,
+                                ipcp_transformation *src_trans,
+                                ipcp_transformation *dst_trans)
+{
+  /* Avoid redundant work of duplicating vectors we will never use.  */
+  if (dst->inlined_to)
+    return;
+  dst_trans->bits = vec_safe_copy (src_trans->bits);
+  dst_trans->m_vr = vec_safe_copy (src_trans->m_vr);
+  ipa_agg_replacement_value *agg = src_trans->agg_values,
+                           **aggptr = &dst_trans->agg_values;
+  while (agg)
+    {
+      *aggptr = ggc_alloc<ipa_agg_replacement_value> ();
+      **aggptr = *agg;
+      agg = agg->next;
+      aggptr = &(*aggptr)->next;
     }
 }
 
index 952c01209f535d717b7c5633a4fb71a7eb3068ed..3422cb2ddb95c614e0f71d6341c1495bbf3a7b0a 100644 (file)
@@ -639,6 +639,25 @@ struct GTY(()) ipcp_transformation
   vec<ipa_bits *, va_gc> *bits;
   /* Value range information.  */
   vec<ipa_vr, va_gc> *m_vr;
+
+  /* Default constructor.  */
+  ipcp_transformation ()
+  : agg_values (NULL), bits (NULL), m_vr (NULL)
+  { }
+
+  /* Default destructor.  */
+  ~ipcp_transformation ()
+  {
+    ipa_agg_replacement_value *agg = agg_values;
+    while (agg)
+      {
+       ipa_agg_replacement_value *next = agg->next;
+       ggc_free (agg);
+       agg = next;
+      }
+    vec_free (bits);
+    vec_free (m_vr);
+  }
 };
 
 void ipa_set_node_agg_value_chain (struct cgraph_node *node,
@@ -759,6 +778,11 @@ public:
       ipcp_transformation_t (symtab, true);
     return summary;
   }
+  /* Hook that is called by summary when a node is duplicated.  */
+  virtual void duplicate (cgraph_node *node,
+                         cgraph_node *node2,
+                         ipcp_transformation *data,
+                         ipcp_transformation *data2);
 };
 
 /* Function summary where the IPA CP transformations are actually stored.  */