Re: [PATCH 1/6] ipa: Bundle vectors describing argument values

2020-10-02 Thread Jan Hubicka
> 2020-09-01  Martin Jambor  
> 
>   * ipa-prop.h (ipa_auto_call_arg_values): New type.
>   (class ipa_call_arg_values): Likewise.
>   (ipa_get_indirect_edge_target): Replaced vector arguments with
>   ipa_call_arg_values in declaration.  Added an overload for
>   ipa_auto_call_arg_values.
>   * ipa-fnsummary.h (ipa_call_context): Removed members m_known_vals,
>   m_known_contexts, m_known_aggs, duplicate_from, release and equal_to,
>   new members m_avals, store_to_cache and equivalent_to_p.  Adjusted
>   construcotr arguments.
>   (estimate_ipcp_clone_size_and_time): Replaced vector arguments
>   with ipa_auto_call_arg_values in declaration.
>   (evaluate_properties_for_edge): Likewise.
>   * ipa-cp.c (ipa_get_indirect_edge_target): Adjusted to work on
>   ipa_call_arg_values rather than on separate vectors.  Added an
>   overload for ipa_auto_call_arg_values.
>   (devirtualization_time_bonus): Adjusted to work on
>   ipa_auto_call_arg_values rather than on separate vectors.
>   (gather_context_independent_values): Adjusted to work on
>   ipa_auto_call_arg_values rather than on separate vectors.
>   (perform_estimation_of_a_value): Likewise.
>   (estimate_local_effects): Likewise.
>   (modify_known_vectors_with_val): Adjusted both variants to work on
>   ipa_auto_call_arg_values and rename them to
>   copy_known_vectors_add_val.
>   (decide_about_value): Adjusted to work on ipa_call_arg_values rather
>   than on separate vectors.
>   (decide_whether_version_node): Likewise.
>   * ipa-fnsummary.c (evaluate_conditions_for_known_args): Likewise.
>   (evaluate_properties_for_edge): Likewise.
>   (ipa_fn_summary_t::duplicate): Likewise.
>   (estimate_edge_devirt_benefit): Adjusted to work on
>   ipa_call_arg_values rather than on separate vectors.
>   (estimate_edge_size_and_time): Likewise.
>   (estimate_calls_size_and_time_1): Likewise.
>   (summarize_calls_size_and_time): Adjusted calls to
>   estimate_edge_size_and_time.
>   (estimate_calls_size_and_time): Adjusted to work on
>   ipa_call_arg_values rather than on separate vectors.
>   (ipa_call_context::ipa_call_context): Construct from a pointer to
>   ipa_auto_call_arg_values instead of inividual vectors.
>   (ipa_call_context::duplicate_from): Adjusted to access vectors within
>   m_avals.
>   (ipa_call_context::release): Likewise.
>   (ipa_call_context::equal_to): Likewise.
>   (ipa_call_context::estimate_size_and_time): Adjusted to work on
>   ipa_call_arg_values rather than on separate vectors.
>   (estimate_ipcp_clone_size_and_time): Adjusted to work with
>   ipa_auto_call_arg_values rather than on separate vectors.
>   (ipa_merge_fn_summary_after_inlining): Likewise.  Adjusted call to
>   estimate_edge_size_and_time.
>   (ipa_update_overall_fn_summary): Adjusted call to
>   estimate_edge_size_and_time.
>   * ipa-inline-analysis.c (do_estimate_edge_time): Adjusted to work with
>   ipa_auto_call_arg_values rather than with separate vectors.
>   (do_estimate_edge_size): Likewise.
>   (do_estimate_edge_hints): Likewise.
>   * ipa-prop.c (ipa_auto_call_arg_values::~ipa_auto_call_arg_values):
>   New destructor.

> @@ -328,14 +326,9 @@ private:
>/* Inline summary maintains info about change probabilities.  */
>vec m_inline_param_summary;
>  
> -  /* The following is used only to resolve indirect calls.  */
> -
> -  /* Vector describing known values of parameters.  */
> -  vec m_known_vals;
> -  /* Vector describing known polymorphic call contexts.  */
> -  vec m_known_contexts;
> -  /* Vector describing known aggregate values.  */
> -  vec m_known_aggs;
> +  /* Even after having calculated clauses, the information about argument
> + values is used to resolve indirect calls.  */
> +  ipa_call_arg_values m_avals;

In cached context we keep the vectors populated only if they are going
to be used by the predicates.  Is this preserved?

Otherwise the patch looks OK.  It would be nice to test it on building
bigger project and see how memory allocation is affeced by your change.

Honza


[PATCH 1/6] ipa: Bundle vectors describing argument values

2020-09-29 Thread Martin Jambor
Hi,

this large patch is mostly mechanical change which aims to replace
uses of separate vectors about known scalar values (usually called
known_vals or known_csts), known aggregate values (known_aggs), known
virtual call contexts (known_contexts) and known value
ranges (known_value_ranges) with uses of either new type
ipa_call_arg_values or ipa_auto_call_arg_values, both of which simply
contain these vectors inside them.

The need for two distinct comes from the fact that when the vectors
are constructed from jump functions or lattices, we really should use
auto_vecs with embedded storage allocated on stack.  On the other hand,
the bundle in ipa_call_context can be allocated on heap when in cache,
one time for each call_graph node.

ipa_call_context is constructible from ipa_auto_call_arg_values but
then its vectors must not be resized, otherwise the vectors will stop
pointing to the stack ones.  Unfortunately, I don't think the
structure embedded in ipa_call_context can be made constant because we
need to manipulate and deallocate it when in cache.

gcc/ChangeLog:

2020-09-01  Martin Jambor  

* ipa-prop.h (ipa_auto_call_arg_values): New type.
(class ipa_call_arg_values): Likewise.
(ipa_get_indirect_edge_target): Replaced vector arguments with
ipa_call_arg_values in declaration.  Added an overload for
ipa_auto_call_arg_values.
* ipa-fnsummary.h (ipa_call_context): Removed members m_known_vals,
m_known_contexts, m_known_aggs, duplicate_from, release and equal_to,
new members m_avals, store_to_cache and equivalent_to_p.  Adjusted
construcotr arguments.
(estimate_ipcp_clone_size_and_time): Replaced vector arguments
with ipa_auto_call_arg_values in declaration.
(evaluate_properties_for_edge): Likewise.
* ipa-cp.c (ipa_get_indirect_edge_target): Adjusted to work on
ipa_call_arg_values rather than on separate vectors.  Added an
overload for ipa_auto_call_arg_values.
(devirtualization_time_bonus): Adjusted to work on
ipa_auto_call_arg_values rather than on separate vectors.
(gather_context_independent_values): Adjusted to work on
ipa_auto_call_arg_values rather than on separate vectors.
(perform_estimation_of_a_value): Likewise.
(estimate_local_effects): Likewise.
(modify_known_vectors_with_val): Adjusted both variants to work on
ipa_auto_call_arg_values and rename them to
copy_known_vectors_add_val.
(decide_about_value): Adjusted to work on ipa_call_arg_values rather
than on separate vectors.
(decide_whether_version_node): Likewise.
* ipa-fnsummary.c (evaluate_conditions_for_known_args): Likewise.
(evaluate_properties_for_edge): Likewise.
(ipa_fn_summary_t::duplicate): Likewise.
(estimate_edge_devirt_benefit): Adjusted to work on
ipa_call_arg_values rather than on separate vectors.
(estimate_edge_size_and_time): Likewise.
(estimate_calls_size_and_time_1): Likewise.
(summarize_calls_size_and_time): Adjusted calls to
estimate_edge_size_and_time.
(estimate_calls_size_and_time): Adjusted to work on
ipa_call_arg_values rather than on separate vectors.
(ipa_call_context::ipa_call_context): Construct from a pointer to
ipa_auto_call_arg_values instead of inividual vectors.
(ipa_call_context::duplicate_from): Adjusted to access vectors within
m_avals.
(ipa_call_context::release): Likewise.
(ipa_call_context::equal_to): Likewise.
(ipa_call_context::estimate_size_and_time): Adjusted to work on
ipa_call_arg_values rather than on separate vectors.
(estimate_ipcp_clone_size_and_time): Adjusted to work with
ipa_auto_call_arg_values rather than on separate vectors.
(ipa_merge_fn_summary_after_inlining): Likewise.  Adjusted call to
estimate_edge_size_and_time.
(ipa_update_overall_fn_summary): Adjusted call to
estimate_edge_size_and_time.
* ipa-inline-analysis.c (do_estimate_edge_time): Adjusted to work with
ipa_auto_call_arg_values rather than with separate vectors.
(do_estimate_edge_size): Likewise.
(do_estimate_edge_hints): Likewise.
* ipa-prop.c (ipa_auto_call_arg_values::~ipa_auto_call_arg_values):
New destructor.
---
 gcc/ipa-cp.c  | 245 ++---
 gcc/ipa-fnsummary.c   | 446 +-
 gcc/ipa-fnsummary.h   |  27 +--
 gcc/ipa-inline-analysis.c |  41 +---
 gcc/ipa-prop.c|  10 +
 gcc/ipa-prop.h| 112 +-
 6 files changed, 452 insertions(+), 429 deletions(-)

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index b3e7d41ea10..292dd7e5bdf 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -3117,30 +3117,40 @@ ipa_get_indirect_edge_target_1 (struct cgraph_edge *ie,
   return target;
 }
 
-

[PATCH 1/6] ipa: Bundle vectors describing argument values

2020-09-07 Thread Martin Jambor
Hi,

this large patch is mostly mechanical change which aims to replace
uses of separate vectors about known scalar values (usually called
known_vals or known_csts), known aggregate values (known_aggs), known
virtual call contexts (known_contexts) and known value
ranges (known_value_ranges) with uses of either new type
ipa_call_arg_values or ipa_auto_call_arg_values, both of which simply
contain these vectors inside them.

The need for two distinct types comes from the fact that when the
vectors are constructed from jump functions or lattices, we really
should use auto_vecs with embedded storage allocated on stack.  On the
other hand, the bundle in ipa_call_context can be allocated on heap when
in cache, one time for each call_graph node.

ipa_call_context is constructible from ipa_auto_call_arg_values but
then its vectors must not be resized, otherwise the vectors will stop
pointing to the stack ones.  Unfortunately, I don't think the
structure embedded in ipa_call_context can be made constant because we
need to manipulate and deallocate it when in cache.

Last week I bootstrapped and tested (and LTO-bootstrapped) this patch
individually, this week I did so for the whole patch set.

OK for trunk?

Thanks,

Martin


gcc/ChangeLog:

2020-09-01  Martin Jambor  

* ipa-prop.h (ipa_auto_call_arg_values): New type.
(class ipa_call_arg_values): Likewise.
(ipa_get_indirect_edge_target): Replaced vector arguments with
ipa_call_arg_values in declaration.  Added an overload for
ipa_auto_call_arg_values.
* ipa-fnsummary.h (ipa_call_context): Removed members m_known_vals,
m_known_contexts, m_known_aggs, duplicate_from, release and equal_to,
new members m_avals, store_to_cache and equivalent_to_p.  Adjusted
construcotr arguments.
(estimate_ipcp_clone_size_and_time): Replaced vector arguments
with ipa_auto_call_arg_values in declaration.
(evaluate_properties_for_edge): Likewise.
* ipa-cp.c (ipa_get_indirect_edge_target): Adjusted to work on
ipa_call_arg_values rather than on separate vectors.  Added an
overload for ipa_auto_call_arg_values.
(devirtualization_time_bonus): Adjusted to work on
ipa_auto_call_arg_values rather than on separate vectors.
(gather_context_independent_values): Adjusted to work on
ipa_auto_call_arg_values rather than on separate vectors.
(perform_estimation_of_a_value): Likewise.
(estimate_local_effects): Likewise.
(modify_known_vectors_with_val): Adjusted both variants to work on
ipa_auto_call_arg_values and rename them to
copy_known_vectors_add_val.
(decide_about_value): Adjusted to work on ipa_call_arg_values rather
than on separate vectors.
(decide_whether_version_node): Likewise.
* ipa-fnsummary.c (evaluate_conditions_for_known_args): Likewise.
(evaluate_properties_for_edge): Likewise.
(ipa_fn_summary_t::duplicate): Likewise.
(estimate_edge_devirt_benefit): Adjusted to work on
ipa_call_arg_values rather than on separate vectors.
(estimate_edge_size_and_time): Likewise.
(estimate_calls_size_and_time_1): Likewise.
(summarize_calls_size_and_time): Adjusted calls to
estimate_edge_size_and_time.
(estimate_calls_size_and_time): Adjusted to work on
ipa_call_arg_values rather than on separate vectors.
(ipa_call_context::ipa_call_context): Construct from a pointer to
ipa_auto_call_arg_values instead of inividual vectors.
(ipa_call_context::duplicate_from): Adjusted to access vectors within
m_avals.
(ipa_call_context::release): Likewise.
(ipa_call_context::equal_to): Likewise.
(ipa_call_context::estimate_size_and_time): Adjusted to work on
ipa_call_arg_values rather than on separate vectors.
(estimate_ipcp_clone_size_and_time): Adjusted to work with
ipa_auto_call_arg_values rather than on separate vectors.
(ipa_merge_fn_summary_after_inlining): Likewise.  Adjusted call to
estimate_edge_size_and_time.
(ipa_update_overall_fn_summary): Adjusted call to
estimate_edge_size_and_time.
* ipa-inline-analysis.c (do_estimate_edge_time): Adjusted to work with
ipa_auto_call_arg_values rather than with separate vectors.
(do_estimate_edge_size): Likewise.
(do_estimate_edge_hints): Likewise.
* ipa-prop.c (ipa_auto_call_arg_values::~ipa_auto_call_arg_values):
New destructor.
---
 gcc/ipa-cp.c  | 245 ++---
 gcc/ipa-fnsummary.c   | 446 +-
 gcc/ipa-fnsummary.h   |  27 +--
 gcc/ipa-inline-analysis.c |  41 +---
 gcc/ipa-prop.c|  10 +
 gcc/ipa-prop.h| 112 +-
 6 files changed, 452 insertions(+), 429 deletions(-)

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index