https://gcc.gnu.org/g:328ef9aaede3c59224e52a1337416e5489e7c6c8
commit r16-1963-g328ef9aaede3c59224e52a1337416e5489e7c6c8 Author: Jan Hubicka <hubi...@ucw.cz> Date: Thu Jul 3 10:25:39 2025 +0200 Enable ipa-cp cloning for cold wrappers of hot functions ipa-cp cloning disables itself for all functions not passing opt_for_fn (node->decl, optimize_size) which disables it for cold wrappers of hot functions where we want to propagate. Since we later want to time saved to be considered hot, we do not need to make this early test. The patch also fixes few other places where AFDO 0 disables ipa-cp. gcc/ChangeLog: * ipa-cp.cc (cs_interesting_for_ipcp_p): Handle correctly GLOBAL0 afdo counts. (ipcp_cloning_candidate_p): Do not rule out nodes !node->optimize_for_size_p (). (good_cloning_opportunity_p): Handle afdo counts as non-zero. Diff: --- gcc/ipa-cp.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 75ea94f2ad85..901d4a5616e9 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -554,6 +554,7 @@ cs_interesting_for_ipcp_p (cgraph_edge *e) /* If we have zero IPA profile, still consider edge for cloning in case we do partial training. */ if (e->count.ipa ().initialized_p () + && e->count.ipa ().quality () != AFDO && !opt_for_fn (e->callee->decl,flag_profile_partial_training)) return false; return true; @@ -617,7 +618,9 @@ ipcp_cloning_candidate_p (struct cgraph_node *node) return false; } - if (node->optimize_for_size_p ()) + /* Do not use profile here since cold wrapper wrap + hot function. */ + if (opt_for_fn (node->decl, optimize_size)) { if (dump_file) fprintf (dump_file, "Not considering %s for cloning; " @@ -3391,9 +3394,10 @@ good_cloning_opportunity_p (struct cgraph_node *node, sreal time_benefit, int size_cost, bool called_without_ipa_profile) { gcc_assert (count_sum.ipa () == count_sum); + if (count_sum.quality () == AFDO) + count_sum = count_sum.force_nonzero (); if (time_benefit == 0 || !opt_for_fn (node->decl, flag_ipa_cp_clone) - || node->optimize_for_size_p () /* If there is no call which was executed in profiling or where profile is missing, we do not want to clone. */ || (!called_without_ipa_profile && !count_sum.nonzero_p ()))