Hello,
> Hi Honza,
>
>
> > On 5 Sep 2025, at 1:30 am, Jan Hubicka <[email protected]> wrote:
> >
> > External email: Use caution opening links or attachments
> >
> >
> > Hi,
> > with -fpartial-profling we ICE building perlbench and gcc from spec2k17
> > since
> > afdo_annotate_cfg applies knowlede about zero profiles too early. This
> > patch
> > moves it after the early exit when profile is 0 everywhere and also fixes
> > formatting issue in the next block.
>
> Thanks for the fix. I also noticed this and posted
> https://gcc.gnu.org/pipermail/gcc-patches/2025-September/694246.html which
> should now be dropped.
>
> I also saw few other ICE’s due to ipa-cp which shows up in ipa-inliner for
> self recursive calls.
>
>
> Patches are in:
> https://gcc.gnu.org/pipermail/gcc-patches/2025-September/694247.html
> https://gcc.gnu.org/pipermail/gcc-patches/2025-September/694248.html
Thanks,
are there other patches pending (except for one with streaming filenames
and updating version of gcov). I plan to try the gcov update on my setup
and see if I get same profiles as with the unique names patch.
I apologize for not pushing the afdo fixes earlier. I hoped to have some
time for hacking during my trip, but it has turned out that organizing
vacation for 6 people took all my time. I should be mostly back at
speed. We should have call tomorrow at 10:30, right? Martin is away,
but I can call call.
Jan
>
> Thanks,
> Kugan
>
> >
> > Bootstrapped/regtesed x86_64-linux, comitted.
> >
> > gcc/ChangeLog:
> >
> > * auto-profile.cc (afdo_annotate_cfg): Apply zero_bbs after early
> > exit for missing profile; fix formating
> >
> > diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc
> > index 7ff952632c3..ce607a68d2e 100644
> > --- a/gcc/auto-profile.cc
> > +++ b/gcc/auto-profile.cc
> > @@ -3875,22 +3875,6 @@ afdo_annotate_cfg (void)
> > set_bb_annotated (bb, &annotated_bb);
> > }
> > }
> > - /* We try to preserve static profile for BBs with 0
> > - afdo samples, but if even static profile agrees with 0,
> > - consider it final so propagation works better. */
> > - for (basic_block bb : zero_bbs)
> > - if (!bb->count.nonzero_p ())
> > - {
> > - update_count_by_afdo_count (&bb->count, 0);
> > - set_bb_annotated (bb, &annotated_bb);
> > - if (dump_file)
> > - {
> > - fprintf (dump_file, " Annotating bb %i with count ",
> > bb->index);
> > - bb->count.dump (dump_file);
> > - fprintf (dump_file,
> > - " (has 0 count in both static and afdo profile)\n");
> > - }
> > - }
> > /* Exit without clobbering static profile if there was no
> > non-zero count. */
> > if (!profile_found)
> > @@ -3926,31 +3910,47 @@ afdo_annotate_cfg (void)
> > free_dominance_info (CDI_POST_DOMINATORS);
> > return;
> > }
> > + /* We try to preserve static profile for BBs with 0
> > + afdo samples, but if even static profile agrees with 0,
> > + consider it final so propagation works better. */
> > + for (basic_block bb : zero_bbs)
> > + if (!bb->count.nonzero_p ())
> > + {
> > + update_count_by_afdo_count (&bb->count, 0);
> > + set_bb_annotated (bb, &annotated_bb);
> > + if (dump_file)
> > + {
> > + fprintf (dump_file, " Annotating bb %i with count ",
> > bb->index);
> > + bb->count.dump (dump_file);
> > + fprintf (dump_file,
> > + " (has 0 count in both static and afdo profile)\n");
> > + }
> > + }
> >
> > /* Update profile. */
> > if (head_count > 0)
> > - {
> > - update_count_by_afdo_count (&ENTRY_BLOCK_PTR_FOR_FN (cfun)->count,
> > - head_count);
> > - set_bb_annotated (ENTRY_BLOCK_PTR_FOR_FN (cfun), &annotated_bb);
> > - if (!is_bb_annotated (ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb,
> > annotated_bb)
> > - || ENTRY_BLOCK_PTR_FOR_FN (cfun)->count
> > - > ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb->count)
> > - {
> > - ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb->count
> > - = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
> > - set_bb_annotated (ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb,
> > - &annotated_bb);
> > - }
> > - if (!is_bb_annotated (EXIT_BLOCK_PTR_FOR_FN (cfun), annotated_bb)
> > - || ENTRY_BLOCK_PTR_FOR_FN (cfun)->count
> > - > EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb->count)
> > - {
> > - EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb->count
> > - = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
> > - set_bb_annotated (EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb,
> > &annotated_bb);
> > - }
> > - }
> > + {
> > + update_count_by_afdo_count (&ENTRY_BLOCK_PTR_FOR_FN (cfun)->count,
> > + head_count);
> > + set_bb_annotated (ENTRY_BLOCK_PTR_FOR_FN (cfun), &annotated_bb);
> > + if (!is_bb_annotated (ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb,
> > annotated_bb)
> > + || ENTRY_BLOCK_PTR_FOR_FN (cfun)->count
> > + > ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb->count)
> > + {
> > + ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb->count
> > + = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
> > + set_bb_annotated (ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb,
> > + &annotated_bb);
> > + }
> > + if (!is_bb_annotated (EXIT_BLOCK_PTR_FOR_FN (cfun), annotated_bb)
> > + || ENTRY_BLOCK_PTR_FOR_FN (cfun)->count
> > + > EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb->count)
> > + {
> > + EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb->count
> > + = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
> > + set_bb_annotated (EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb,
> > &annotated_bb);
> > + }
> > + }
> >
> > /* Calculate, propagate count and probability information on CFG. */
> > afdo_calculate_branch_prob (&annotated_bb);
>