This is an archive of the discontinued LLVM Phabricator instance.

Fix branch coverage merging across function instantiations
ClosedPublic

Authored by alanphipps on May 10 2021, 1:28 PM.

Details

Summary

When I made the upstream commit for branch coverage support in code-coverage in January, I made an incorrect assumption that branch coverage numbers (covered branch and total branches) should be accumulated across function instantiations. This is not what is done for lines and regions, where the maximum line/region coverage found in a function instantiation across an instantiation group is returned. For example, if a function template definition has 2 total branches, the branch coverage would be reported as an accumulated total across all instantiations (8 total branches across 4 instantiations).

The correct assumption for the FunctionCoverageSummary::get(const InstantiationGroup &Group, ...) routine is that the summary it returns should agree with the function definition in the source code on lines, regions, and branches. So we should do the same thing for branch coverage as we do for line and region coverage. So if a function template definition has 2 total branches, the summary should also reflect branch coverage for 2 total branches.

This change corrects the implementation for the branch coverage summary to do the same thing for branches that is done for lines and regions. That is, across function instantiations in an instantiation group, the maximum branch coverage found in any of those instantiations is returned, with the total number of branches being the same across instantiations.

Diff Detail

Event Timeline

alanphipps requested review of this revision.May 10 2021, 1:28 PM
alanphipps created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2021, 1:28 PM
This revision is now accepted and ready to land.May 10 2021, 8:50 PM
This revision was landed with ongoing or failed builds.May 11 2021, 8:44 AM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.May 11 2021, 9:24 AM

Looks like this breaks tests on windows: http://45.33.8.238/win/38516/step_11.txt

PTAL, and revert for now if it takes a while to fix.

Looks like this breaks tests on windows: http://45.33.8.238/win/38516/step_11.txt

PTAL, and revert for now if it takes a while to fix.

Thanks -- Backslash issue was tripping up Windows. I fixed it and will reland.

I saw this fix was backported to the release/12.x branch, was there a bug for this?

I saw this fix was backported to the release/12.x branch, was there a bug for this?

I did not file an official bug for this issue -- should I have? My original commit on 12.x also needed to be fixed, but if I missed something in the process for updating release branches, let me know. Thanks!

I saw this fix was backported to the release/12.x branch, was there a bug for this?

I did not file an official bug for this issue -- should I have? My original commit on 12.x also needed to be fixed, but if I missed something in the process for updating release branches, let me know. Thanks!

OK, I will revert that commit on the 12.x branch then. Can you please file a bug for this patch and mark it as blocker of the release-12.0.1 metabug? I typically review and try to get an ack from at least on other person before backporting patches.

OK, I will revert that commit on the 12.x branch then. Can you please file a bug for this patch and mark it as blocker of the release-12.0.1 metabug? I typically review and try to get an ack from at least on other person before backporting patches.

Done - thank you!

https://bugs.llvm.org/show_bug.cgi?id=50394