https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86957
Bug ID: 86957 Summary: gcc should warn about missing profiles for a compilation unit or a new function with -fprofile-use Product: gcc Version: 9.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: ibhagatgnu at gmail dot com CC: mliska at suse dot cz Target Milestone: --- When using -fprofile-use in the FDO build, gcc currently does not warn about about the following two cases. Both the cases are related to a missing profiles. Discussed here on mailing list https://gcc.gnu.org/ml/gcc/2018-08/msg00048.html CASE 1 : Missing profile for a new function ------------------------------------------- If a new function foo() is added to the file, gcc only warns about those existing functions whose source locations have been impacted by foo() by issuing the following : "warning : source locations for function 'XXX' have changed, the profile data may be out of date [-Werror=coverage-mismatch]" Proposal to add a warning for the new function foo() along the lines of - "warning : profile for function ‘XXX’ not found in profile data [-Wmissing-profile]" Note that, the corner case of foo() being added to the end of the file is exclusively covered by the proposed -Wmissing-profile CASE 2 : Missing profile for a compilation unit ----------------------------------------------- This is the case when, e.g., a new source file is added to the project after profile generation phase. Also, the case when somehow .gcda files are wiped out in a make clean etc. It is worth informing the user that profile generation is due. Proposal to add a warning per file along the lines of - "warning : profile count data file not found, regenerating profiles may help [-Wmissing-profile]" To contrast, -Wcoverage-mismatch covers the cases when profiles are STALE. -Wmissing-profile is intended to cover the cases when there is NO profile. I propose to keep the behaviour of -Wmissing-profile to be consistent with -Wcoverage-mismatch in that : 1. Both should be on by default and treated as errors by default in -fprofile-use FDO build 2. A user must use -Wno-error to just see them as warnings (with -fprofile-use).