Auto-FDO/FDO profile comparator
the patch I sent from airport only worked if you produced the gcda files with
unpatched compiler. For some reason auto-profile reading is interwinded into
gcov reading which is not necessary. Here is cleaner version which also
makes the format bit more convenient. One can now grep as:
grep "bb.*fdo.*very hot.*cold" *.profile | sort -n -k 5 -r | less
digits_2/30 bb 307 fdo
10273284651 (very hot) afdo 0 (auto FDO) (cold) scaled 0 diff -
10273284651, -100.00%
digits_2/30 bb 201 fdo
2295561442 (very hot) afdo 19074 (auto FDO) (cold) scaled
1341585 diff -
2294219857, -99.94%
digits_2/30 bb 203 fdo
1236123372 (very hot) afdo 9537 (auto FDO) (cold) scaled 670792 diff -
1235452580, -99.95%
digits_2/30 bb 200 fdo
1236123372 (very hot) afdo 9537 (auto FDO) (cold) scaled 670792 diff -
1235452580, -99.95%
digits_2/30 bb 202 fdo
1059438070 (very hot) afdo 9537 (auto FDO) (cold) scaled 670792 diff -
1058767278, -99.94%
new_solver/9 bb 246 fdo
413879041 (very hot) afdo 76594 (guessed) (cold) scaled
5387299 diff -
408491742, -98.70%
new_solver/9 bb 167 fdo
413792205 (very hot) afdo 76594 (guessed) (cold) scaled
5387299 diff -
408404906, -98.70%
new_solver/9 bb 159 fdo
387809230 (very hot) afdo 57182 (guessed) (cold) scaled
4021940 diff -
383787290, -98.96%
new_solver/9 bb 158 fdo
387809230 (very hot) afdo 60510 (guessed) (cold) scaled
4256018 diff -
383553212, -98.90%
new_solver/9 bb 138 fdo
387809230 (very hot) afdo 40917 (guessed) (cold) scaled
2877929 diff -
384931301, -99.26%
new_solver/9 bb 137 fdo
387809230 (very hot) afdo 43298 (guessed) (cold) scaled
3045398 diff -
384763832, -99.21%
This dumps basic blocks that do have large counts by normal profile feedback
but autofdo gives them small count (so they get cold). These seems to be
indeed mostly basic blocks controlling loops.
gcc/ChangeLog:
* auto-profile.cc (afdo_hot_bb_threshod): New global
variable.
(maybe_hot_afdo_count_p): New function.
(autofdo_source_profile::read): Do not set up dump file;
set afdo_hot_bb_threshod.
(afdo_annotate_cfg): Handle partial training.
(afdo_callsite_hot_enough_for_early_inline):
Use maybe_hot_afdo_count_p.
(auto_profile_offline::execute): Read autofdo file.
* auto-profile.h (maybe_hot_afdo_count_p): Declare.
(afdo_hot_bb_threshold): Declare.
* coverage.cc (read_counts_file): Also set gcov_profile_info.
(coverage_init): Do not read autofdo file.
* opts.cc (enable_fdo_optimizations): Add autofdo parameter;
do not set flag_branch_probabilities and flag_profile_values
with it.
(common_handle_option): Update.
* passes.cc (finish_optimization_passes): Do not end branch
prob here.
(pass_manager::dump_profile_report): Also mark change after
autofdo pass.
* profile.cc: Include auto-profile.h
(gcov_profile_info): New global variable.
(struct afdo_fdo_record): New struture.
(compute_branch_probabilities): Record afdo profile.
(end_branch_prob): Dump afdo/fdo profile comparsion.
* profile.h (gcov_profile_info): Declarre.
* tree-profile.cc (tree_profiling): Call end_branch_prob
(pass_ipa_tree_profile::gate): Also enable with autoFDO