Open
Description
The export mode of tool "llvm-cov" for format "lcov" does not combine the branch counts of C++ template functions instantiations.
A preceding discussion describes the issue in detail:
https://discourse.llvm.org/t/profiling-report-with-branch-coverage-for-templates-is-misleading/82323
Activity
stma247 commentedon Oct 9, 2024
I am already working on a solution. The PR will follow soon.
[llvm-cov] Fix branch counts of template functions (llvm#111743)
[llvm-cov] Fix branch counts of template functions (llvm#111743)
[llvm-cov] Fix branch counts of template functions (llvm#111743)
[llvm-cov] Fix branch counts of template functions (llvm#111743)
[llvm-cov] Fix branch counts of template functions (llvm#111743)
chapuni commentedon Nov 21, 2024
Thanks for working on it.
Could it be applied to text and html as well?
evodius96 commentedon Nov 21, 2024
This is only really for LCOV exporting. The text and html from
llvm-cov show
summaries show the right information.chapuni commentedon Nov 21, 2024
From llvm/test/tools/llvm-cov/branch-templates.cpp
I'll investigate further later.
evodius96 commentedon Nov 21, 2024
Hi @chapuni
Sorry, I didn't elaborate -- this is primarily an effect of the summary report. With
llvm-cov show
the summary report correctly merges the data across the corresponding instantiations showing the union of the data, whereas withllvm-cov export --format=lcov
it was not correctly rendering the union with BRDA. As a result, LCOV was not displaying the summary correctly.The source-level report that you show shows the individual branch coverage information across the instantiations, but the report summary for this should have merged this data and ought to show 100% coverage for the condition.
[llvm-cov] Fix branch counts of template functions (llvm#111743)
19 remaining items
bartlettroscoe commentedon Apr 8, 2025
Yes, but I will argue you still want to have the overall coverage metrics for the template function, in addition to its specific instantiations. The way
llvm-cov show
, for example, displays coverage information for template functions with lots of instantiations is about worthless (you can't see the forest for the trees). I will post an issue about how to fix this shortly (i.e. wrapping details for the instantiations in<details> ... </details>
blocks). And for that, we will need combined branch metrics for the template function across all instantiations.Update: I posted:
describing the problem with the way that
llvm-cov show
generates HTML coverage files and how to easily fix the problem.But we would need to compute the cumulative branch coverage metrics for a template function over all of its instantaitions in order to implement #134927.
[llvm-cov] Fix branch counts of template functions (llvm#111743)
[llvm-cov] Fix branch counts of template functions (llvm#111743)
[llvm-cov] Fix branch counts of template functions (llvm#111743)
[llvm-cov] Fix branch counts of template functions (llvm#111743)
[llvm-cov] Fix branch counts of template functions (llvm#111743)
[llvm-cov] Fix branch counts of template functions (second attempt) (#…
[llvm-cov] Fix branch counts of template functions (second attempt) (l…
[llvm-cov] Fix branch counts of template functions (second attempt) (l…
[llvm-cov] Fix branch counts of template functions (second attempt) (l…
[llvm-cov] Fix branch counts of template functions (second attempt) (l…