[PATCH] D121390: [llvm-cov gcov] Fix calculating coverage statistics of template functions
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 13 15:14:06 PDT 2022
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.
> llvm-cov gcov tmpl.cpp -f
...
Function '_Z4testILi2EEiv'
Lines executed:-nan% of 0
Perhaps include
Function '_Z4testILi1EEiv'
Lines executed:100.00% of 1
in the message as well.
================
Comment at: llvm/lib/ProfileData/GCOV.cpp:666
si.startLineToFunctions[f.startLine].push_back(&f);
+ llvm::SmallSet<uint32_t, 16> lines;
+ llvm::SmallSet<uint32_t, 16> linesExec;
----------------
Optional: `llvm::` is usually omitted for llvm/lib files.
================
Comment at: llvm/test/tools/llvm-cov/gcov/tmpl.cpp:14
+int main() {
+ return test<1>(1) +
+ test<1>(2) +
----------------
ikudrin wrote:
> MaskRay wrote:
> > It's useful to dump `llvm-cov gcov -t` and test the line counts for the three lines, to better leverage this test file.
> I'm not sure I follow you. The patch fixes and the test checks the coverage statistics for template functions (`-f`), not execution counts (`-t`).
I suggest using `llvm-cov gcov -t -f` to better leverage the test. I know this patch fixes an issue. But with little efforts (adding line execution counts for `-t`) this patch can add more coverage that we currently lack (there are very little C++ template tests): `test<1>() + test<2>();` on the same line may be interesting for the line execution counts.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121390/new/
https://reviews.llvm.org/D121390
More information about the llvm-commits
mailing list