On 08/13/2018 06:32 AM, Martin Liška wrote:
On 08/09/2018 08:05 PM, Indu Bhagat wrote:
Wcoverage-mismatch is meant to "Warn in case profiles in -fprofile-use do not
match"

Currently, gcc compiler warns about the following two cases of source code
changes which alert the programmer to re-generate the profiles :

1. Control flow mismatch
    If functions' control flow has been altered after profile generation, the
    profile count data will not be able to match the cfg_checksum.
    Hence the warning, "warning: the control flow of function 'XXX' does not
    match its profile data (counter 'YYY') [-Werror=coverage-mismatch]"

2. Function is physically moved to a different location
    If existing functions are physically swapped in the source file, gcc alerts
    the user about potentially stale profiles for all the affected functions.

    Hence the warning, "warning : source locations for function 'XXX' have
    changed, the profile data may be out of date [-Werror=coverage-mismatch]"

    So, if new function foo() is added in the source file before existing
    functions, gcc alerts the user about potentially stale profiles of the
    already seen functions.
          Note however, there is no warning about the new function foo(). 
Hence, my
    proposal #3 below which will cover foo() in this scenario.
Hello.

I would appreciate a warning for that. Will you work on a patch or should I do
it myself?

Thanks for your response. Yes, I will work on this. I will create a bugzilla for both these new warnings.
Indu

Proposing to add the following cases which are not currently covered :

3. If a new function foo() is added to the file. Proposal to add a warning along
    the lines of -
    "warning : profile for function ‘XXX’ not found in profile data 
[-Wcoverage-mismatch]"
       The corner case of foo() being added to the end of the file is 
exclusively
    covered by #3.

4. A new source file is added to the project after profile generation phase.
    Proposal to add a warning per function along the lines of -
    "warning : profile count data file not found, regenerating profiles may help 
[-Wcoverage-mismatch]"
I was considering some time ago a warning when a profile is missing for a 
compilation unit. It's not
only situation when a file is added. But one can also wipe somehow .gcda files 
in make clean and
it worth informing a user. I tend to come up with a new warning maybe for it. 
Again are you planning
to work on that?

May I please ask you for a bugzilla entry both these issues?

Thanks,
Martin

For both #3 and #4, gcc currently does not warn. Although, one can infer that
the count profile data for a specific function / file are missing from the dump
files, adding warnings #3 and #4 makes the coverage-mismatch set of warnings
more complete for a better end user experience.


Reply via email to