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; if (dump_file) fprintf (dump_file, "\n\n"); if (flag_checking) @@ -3246,16 +3253,17 @@ all_callee_accesses_present_p (isra_param_desc *param_desc, enum acc_prop_kind {ACC_PROP_DONT, ACC_PROP_COPY, ACC_PROP_CERTAIN}; -/* Attempt to propagate all definite accesses from ARG_DESC to PARAM_DESC, if - they would not violate some constraint there. If successful, return NULL, - otherwise return the string reason for failure (which can be written to the - dump file). DELTA_OFFSET is the known offset of the actual argument withing - the formal parameter (so of ARG_DESCS within PARAM_DESCS), ARG_SIZE is the - size of the actual argument or zero, if not known. In case of success, set - *CHANGE_P to true if propagation actually changed anything. */ +/* Attempt to propagate all definite accesses from ARG_DESC to PARAM_DESC, + (which belongs to CALLER) if they would not violate some constraint there. + If successful, return NULL, otherwise return the string reason for failure + (which can be written to the dump file). DELTA_OFFSET is the known offset + of the actual argument withing the formal parameter (so of ARG_DESCS within + PARAM_DESCS), ARG_SIZE is the size of the actual argument or zero, if not + known. In case of success, set *CHANGE_P to true if propagation actually + changed anything. */ static const char * -pull_accesses_from_callee (isra_param_desc *param_desc, +pull_accesses_from_callee (cgraph_node *caller, isra_param_desc *param_desc, isra_param_desc *arg_desc, unsigned delta_offset, unsigned arg_size, bool *change_p) @@ -3335,7 +3343,7 @@ pull_accesses_from_callee (isra_param_desc *param_desc, return NULL; if ((prop_count + pclen - > (unsigned) param_ipa_sra_max_replacements) + > (unsigned) opt_for_fn (caller->decl, param_ipa_sra_max_replacements)) || size_would_violate_limit_p (param_desc, param_desc->size_reached + prop_size)) return "propagating accesses would violate the count or size limit"; @@ -3455,7 +3463,8 @@ param_splitting_across_edge (cgraph_edge *cs) else { const char *pull_failure - = pull_accesses_from_callee (param_desc, arg_desc, 0, 0, &res); + = pull_accesses_from_callee (cs->caller, param_desc, arg_desc, + 0, 0, &res); if (pull_failure) { if (dump_file && (dump_flags & TDF_DETAILS)) @@ -3516,7 +3525,7 @@ param_splitting_across_edge (cgraph_edge *cs) else { const char *pull_failure - = pull_accesses_from_callee (param_desc, arg_desc, + = pull_accesses_from_callee (cs->caller, param_desc, arg_desc, ipf->unit_offset, ipf->unit_size, &res); if (pull_failure) diff --git a/gcc/params.opt b/gcc/params.opt index 3cd6d7d481d..02584740640 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -235,7 +235,7 @@ Common Joined UInteger Var(param_ipa_max_switch_predicate_bounds) Init(5) Param Maximal number of boundary endpoints of case ranges of switch statement used during IPA functoin summary generation. -param=ipa-sra-max-replacements= -Common Joined UInteger Var(param_ipa_sra_max_replacements) Init(8) IntegerRange(0, 16) Param +Common Joined UInteger Var(param_ipa_sra_max_replacements) Optimization Init(8) IntegerRange(0, 16) Param Maximum pieces that IPA-SRA tracks per formal parameter, as a consequence, also the maximum number of replacements of a formal parameter. -param=ipa-sra-ptr-growth-factor= -- 2.24.1