Proposal to add diagnostics to know which functions were not run in the training run in FDO.
Motivation : When using FDO, it is often desirable to know the quality of function profile. This means knowing which functions have STALE, NO/MISSING or ZERO profiles. GCC has diagnostics for STALE (Wcoverage-mismatch) and NO/MISSING profiles (Wmissing-profile). Stats regarding number of bbs, branches, number of edges profiled etc. are available in the dump file. It will be useful to add a new diagnostic, -Wprofile-quality for the case when there are ZERO profiles, i.e, those functions which were not exercised in the training run. (I submitted a patch https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00508.html after which there will be some reliable information in the -fdump-ipa-profile dump file for the user to grep, but adding a adding a diagnostic gives user a direct way.) For example, after the above-mentioned patch precise-ipa-dump-optinfo.patch.ver1 : After the posted patch precise-ipa-dump-optinfo.patch.ver1, the way to know which functions were not run in the training run in O1, O2, O3 etc is to grep for text in the -fdump-ipa-profile dump file: "(estimated locally, globally 0)" Proposal : Provide a more direct way than above. There are two options : OPTION 1 : WARNING ONLY APPROACH -------------------------------- 1. Add a new warning -Wprofile-quality=[none|file|all]. Warning is disabled by default with -fprofile-use. -Wprofile-quality -Wprofile-quality=file emits a warning message for each compilation unit summarising the number of functions which were not profiled in the training run. "warning: XX out of YY functions not exercised in training run [-Wprofile-quality=]" -Wprofile-quality=all emits a warning message for each function which was not run in the training run, in addition to the above "warning: function XXXX not exercised in training run [-Wprofile-quality=]" Sample Output : "warning: XX out of YY functions not exercised in training run [-Wprofile-quality=]" "warning: function AAA not exercised in training run [-Wprofile-quality=]" "warning: function BBB not exercised in training run [-Wprofile-quality=]" OPTION 2 : WARNING + OPT-INFO APPROACH -------------------------------------- 1. Add a new warning -Wprofile-quality. Warning is disabled by default. -Wprofile-quality emits a warning message for each compilation unit summarizing the number of functions which were profiled in the training run. "warning: XX out of YY functions not exercised in training run [-Wprofile-quality=]" 2. Next, using the dump_printf_loc API, add messages of MSG_NOTE dump_flag for each function that was not run in the training run. This information is then available to the user via flag -fopt-info-ipa. Which option is preferable ? OPTION 1 has the advantage that it is direct and information will not get diluted as opt-info framework evolves. Thanks