[PATCH] Initial code coverage mapping data structures, and reader and writers + C interface for ProfileData library

Nick Lewycky nicholas at mxc.ca
Fri Jun 27 22:33:14 PDT 2014


Alex L wrote:
>
>
>
> 2014-06-25 17:57 GMT-07:00 Eric Christopher <echristo at gmail.com
> <mailto:echristo at gmail.com>>:
>
>     So, any reason why we want the new coverage system? You didn't seem to
>     highlight what you saw wrong with gcov or the way it works.
>
>     I saw your original mail and it didn't have a lot of motivation here.
>
>     Thanks.
>
>     -eric
>
>
> I am not very familiar with GCOV,

Here's how GCOV works. At compile time we break down the program into 
blocks of source-lines that get executed together. A control flow graph 
of those blocks is formed, and each block has a reference to a set of 
file:line which are executed if the block is executed. This graph is 
emitted into the .gcno ("notes") file, and the program is instrumented 
to emit counters with references to those blocks.

In our implementation, clang emits debug info which an llvm pass later 
transforms into a .gcno file and adds matching instrumentation calls to 
the IR. If debug info was not requested by the user, we strip out the 
debug info before .o emission.

This leads to certain warts like uninstantiated function templates not 
being considered "not covered code" since they aren't executable (in the 
debug info) to begin with.

  but the primary motivation for the new
> coverage system is to provide very accurate execution counts for a
> program. This would enable us to provide modern, high quality tools for
> code coverage analysis.
>
> By very accurate I mean that instead of reasoning about code coverage
> for basic blocks, branches and even lines, we would be able to reason
> about code coverage for the regions of source code that resemble the
> corresponding AST. This would enable the coverage tool to locate and
> mark the exact regions of code that weren't executed, even if the IR for
> those regions was transformed by the optimizer. I think that GCOV fails
> to provide coverage for certain constructs when optimizations are
> enabled.

That is gcc specific. Clang produces the same gcov information with 
optimizations on and off. We could also do what gcc does if we wanted to 
implement that by running the optimizations first and doing GCOV 
instrumentation second using the post-optimization debug info.

Nick

  Also, I think that GCOV doesn't really show good coverage for
> the lines that have multiple regions with different execution counts,
> and the new system will enable us to create a tool which will have a
> better way to deal with this particular situation.
>
> Also, the GCOV way produces separate mapping files and counter files for
> each source file/object file, which can be somewhat inconvenient. In the
> new system we pack the mapping data into the generated IR and allow it
> to be merged by the linker, and as a result of that all our mapping
> information is embedded inside the program's executable.
>
> The new coverage tool will be able to provide a more interactive
> experience as well, by showing reports or code coverage only for
> selected items like certain functions, classes, etc.
>
> Also, this new coverage system will provide a library which various code
> coverage tools can use to make coverage reports without the need to
> parse the output of GCOV.
>
>     On Wed, Jun 25, 2014 at 4:32 PM, Alex L <arphaman at gmail.com
>     <mailto:arphaman at gmail.com>> wrote:
>      > Hi everyone,
>      > This is a first patch that implements the data structures,
>     readers and
>      > writers used by the new code coverage system. I added the new
>     code to the
>      > ProfileData library. I also added a very minimal C api for the
>     ProfileData
>      > library.
>      >
>      > http://reviews.llvm.org/D4301
>      >
>      >
>      >
>      > _______________________________________________
>      > llvm-commits mailing list
>      > llvm-commits at cs.uiuc.edu <mailto:llvm-commits at cs.uiuc.edu>
>      > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>      >
>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list