[llvm-dev] gcov vs llvm coverage mapping on line execution counts (original) (raw)

Fangrui Song via llvm-dev llvm-dev at lists.llvm.org
Wed May 13 22:30:30 PDT 2020


(Quick example: gcc a.c --coverage; ./a.out; gcov a. => a.c.gcov) gcov computes line execution counts with this approach:

https://github.com/gcc-mirror/gcc/blob/master/gcc/gcov.c#L2684-L2690 /* The user expects the line count to be the number of times a line has been executed. Simply summing the block count will give an artificially high number. The Right Thing is to sum the entry counts to the graph of blocks on this line, then find the elementary cycles of the local graph and add the transition counts of those cycles. */

i.e. count from blocks outside the line + cycle count

cycle count is convoluted:

llvm coverage mapping uses a very different approach (https://github.com/llvm/llvm-project/blob/master/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp#L769) How do we compute ExecutionCount?



More information about the llvm-dev mailing list