]> git.ipfire.org Git - thirdparty/gcc.git/commit
Analyze SRA candidates in ipa-fnsummary
authorHonza <jh@ryzen3.suse.cz>
Sun, 18 Jun 2023 16:58:26 +0000 (18:58 +0200)
committerHonza <jh@ryzen3.suse.cz>
Sun, 18 Jun 2023 16:58:26 +0000 (18:58 +0200)
commit5a1ef1cfac005370d0a5a0f85798724cb2c9cf5e
tree1ada25a42566c1e6b09f3f884dfdf24a266a5116
parentaf29d0d6b75f9e5ad69820488972027fe4634850
Analyze SRA candidates in ipa-fnsummary

this patch extends ipa-fnsummary to anticipate statements that will be removed
by SRA.  This is done by looking for calls passing addresses of automatic
variables.  In function body we look for dereferences from pointers of such
variables and mark them with new not_sra_candidate condition.

This is just first step which is overly optimistic.  We do not try to prove that
given automatic variable will not be SRAed even after inlining.  We now also
optimistically assume that the transformation will always happen.  I will restrict
this in a followup patch, but I think it is useful to gether some data on how
much code is affected by this.

This is motivated by PR109849 where we fail to fully inline push_back.
The patch alone does not solve the problem even for -O3, but improves
analysis in this case.

gcc/ChangeLog:

PR tree-optimization/109849
* ipa-fnsummary.cc (evaluate_conditions_for_known_args): Add new parameter
ES; handle ipa_predicate::not_sra_candidate.
(evaluate_properties_for_edge): Pass es to
evaluate_conditions_for_known_args.
(ipa_fn_summary_t::duplicate): Handle sra candidates.
(dump_ipa_call_summary): Dump points_to_possible_sra_candidate.
(load_or_store_of_ptr_parameter): New function.
(points_to_possible_sra_candidate_p): New function.
(analyze_function_body): Initialize points_to_possible_sra_candidate;
determine sra predicates.
(estimate_ipcp_clone_size_and_time): Update call of
evaluate_conditions_for_known_args.
(remap_edge_params): Update points_to_possible_sra_candidate.
(read_ipa_call_summary): Stream points_to_possible_sra_candidate
(write_ipa_call_summary): Likewise.
* ipa-predicate.cc (ipa_predicate::add_clause): Handle not_sra_candidate.
(dump_condition): Dump it.
* ipa-predicate.h (struct inline_param_summary): Add
points_to_possible_sra_candidate.

gcc/testsuite/ChangeLog:

PR tree-optimization/109849
* g++.dg/ipa/devirt-45.C: Update template.
gcc/ipa-fnsummary.cc
gcc/ipa-predicate.cc
gcc/ipa-predicate.h
gcc/testsuite/g++.dg/ipa/devirt-45.C