[cfe-dev] probable bug in clang source based coverage

Vedant Kumar via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 23 11:51:43 PDT 2017


> On Mar 23, 2017, at 8:35 AM, MichaƂ Pszona <pszona at gmail.com> wrote:
> 
> Vedant,
> 
> First of all, thank you so much for your help!
> It took me some time to wrap my mind around this and actually
> realized, that the information in the segments array is more verbose
> than I was expecting :)
> I was assuming this something similar to what regions array in the
> function entry is.
> 
>> 
>> The `IsRegionEntry` field is just used as a hint by llvm-cov to compute better line execution counts, and to determine when it is appropriate to create tooltips for regions within a line.
>> 
> 
> This might be confusing as my tool can't figure out which region
> should the counters be inherited from.

llvm-cov doesn't try to evaluate counter expressions either.

Let me frame the problem: there may be multiple profiling regions that start on a given line, and we want to find the "most interesting one", that can be used to get the best line execution count.

`IsRegionEntry` provides a heuristic for deciding which region counts are interesting.


>> What kind of source annotations are you interested in? If it's similar to something llvm-cov does, I can provide more details about how it works.
>> 
> 
> Yes, it is basically the same job as SourceCoverageViewHTML class
> does, but it operates on the exported json data.
> The tool I'm developing is aggregating the data from llvm-cov's export
> command from different executables and runs.

If you want to aggregate coverage reports from multiple executables, you can use llvm-cov's "-object" flag to pass in multiple binaries.

You may be interested in this helper script, which has an example usage of the "-object" option:

  https://github.com/llvm-mirror/llvm/blob/master/utils/prepare-code-coverage-artifact.py


> So the way I understand it so far is as follows:
> The positions in the segments array are actually markers for the code
> "colorization" (based on hit count)
> Wherever a new marker is set, it is valid for the rest of the line and
> all the lines until a new marker is set.
> The code can be marked as (based only on the current marker):
>   - covered when the hasCount field is set and Count is greater than 0.
>   - uncovered when hasCount field is set but count is 0
>   - skipped/uninstrumented otherwise (hasCount should be 0)
> As far as I can see, the IsRegionCount field is only used to determine
> if you need to colorize multiple regions in one line and produce a
> tooltip.
> 
> Can you confirm this is correct?

This looks correct.

vedant


More information about the cfe-dev mailing list