diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2025-09-04 17:29:07 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@ucw.cz> | 2025-09-04 17:29:07 +0200 |
commit | 79d9ff28c2da0fde4aae0c034d7d39ef27558c14 (patch) | |
tree | 79aed86a36d72dd3649910bca40beaae90264021 | |
parent | 1da3c4d90e678af0fed89c5638c97a41e5e04547 (diff) | |
download | gcc-79d9ff28c2da0fde4aae0c034d7d39ef27558c14.zip gcc-79d9ff28c2da0fde4aae0c034d7d39ef27558c14.tar.gz gcc-79d9ff28c2da0fde4aae0c034d7d39ef27558c14.tar.bz2 |
Fix ICE with auto-fdo and -fpartial-profiling
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.
gcc/ChangeLog:
* auto-profile.cc (afdo_annotate_cfg): Apply zero_bbs after early
exit for missing profile; fix formating
-rw-r--r-- | gcc/auto-profile.cc | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc index 7ff9526..ce607a6 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); |