> Hi, > > On Fri, Jan 03 2020, Martin Liška wrote: > > Hi. > > > > This is similar transformation for IPA passes. This time, > > one needs to use opt_for_fn in order to get the right > > parameter values. > > > > @Martin, Honza: > > There are last few remaining parameters which should use > > opt_for_fn: > > > > param_ipa_sra_max_replacements > > IPA-CP: Always access param_ipa_sra_max_replacements through opt_for_fn > > 2020-01-07 Martin Jambor <mjam...@suse.cz> > > * params.opt (param_ipa_sra_max_replacements): Mark as Optimization. > * ipa-sra.c (scanned_node): New variable. > (allocate_access): Use it to get param_ipa_sra_max_replacements. > (ipa_sra_summarize_function): Set up scanned_node. > (pull_accesses_from_callee): New parameter caller, use it to get > param_ipa_sra_max_replacements. > (param_splitting_across_edge): Pass the caller to > pull_accesses_from_callee. > --- > gcc/ipa-sra.c | 33 +++++++++++++++++++++------------ > gcc/params.opt | 2 +- > 2 files changed, 22 insertions(+), 13 deletions(-) > > diff --git a/gcc/ipa-sra.c b/gcc/ipa-sra.c > index a051a9f2154..133ed687509 100644 > --- a/gcc/ipa-sra.c > +++ b/gcc/ipa-sra.c > @@ -521,6 +521,10 @@ ipa_sra_call_summaries::duplicate (cgraph_edge *, > cgraph_edge *, > > /* With all GTY stuff done, we can move to anonymous namespace. */ > namespace { > +/* Functions which currently has its body analyzed. */ > + > +cgraph_node *scanned_node; > + > /* Quick mapping from a decl to its param descriptor. */ > > hash_map<tree, gensum_param_desc *> *decl2desc; > @@ -1265,7 +1269,8 @@ allocate_access (gensum_param_desc *desc, > HOST_WIDE_INT offset, HOST_WIDE_INT size) > { > if (desc->access_count > - == (unsigned) param_ipa_sra_max_replacements) > + == (unsigned) opt_for_fn (scanned_node->decl, > + param_ipa_sra_max_replacements)) > { > disqualify_split_candidate (desc, "Too many replacement candidates"); > return NULL; > @@ -2472,6 +2477,7 @@ ipa_sra_summarize_function (cgraph_node *node) > node->order); > if (!ipa_sra_preliminary_function_checks (node)) > return; > + scanned_node = node; > gcc_obstack_init (&gensum_obstack); > isra_func_summary *ifs = func_sums->get_create (node); > ifs->m_candidate = true; > @@ -2526,6 +2532,7 @@ ipa_sra_summarize_function (cgraph_node *node) > delete decl2desc; > decl2desc = NULL; > obstack_free (&gensum_obstack, NULL); > + scanned_node = NULL;
It is your code. having static var to track currently analyzed function is bit ugly, and I am not sure if you don't have current_function_decl set to that function in all cases. But I will leave this to your decision. Patch is OK either in this form or with tracking updated. Honza