Skip to content

Commit 33d312b

Browse files
committed
Revert "[Coverage] Fix branch coverage merging in FunctionCoverageSummary::get() for instantiation"
This reverts commit b89942c. There are issues with this patch and also no tracking bug for it.
1 parent aa97726 commit 33d312b

File tree

3 files changed

+6
-21
lines changed

3 files changed

+6
-21
lines changed

llvm/test/tools/llvm-cov/branch-templates.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: llvm-profdata merge %S/Inputs/branch-templates.proftext -o %t.profdata
22
// RUN: llvm-cov show --show-expansions --show-branches=count %S/Inputs/branch-templates.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
33
// RUN: llvm-cov report --show-branch-summary %S/Inputs/branch-templates.o32l -instr-profile %t.profdata -show-functions -path-equivalence=/tmp,%S %s | FileCheck %s -check-prefix=REPORT
4-
// RUN: llvm-cov report --show-branch-summary %S/Inputs/branch-templates.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s -check-prefix=REPORTFILE
54

65
#include <stdio.h>
6+
77
template<typename T>
88
void unused(T x) {
99
return;
@@ -45,17 +45,3 @@ int main() {
4545
// REPORT-NEXT: _Z4funcIfEiT_ 5 2 60.00% 7 3 57.14% 2 1 50.00%
4646
// REPORT-NEXT: ---
4747
// REPORT-NEXT: TOTAL 22 7 68.18% 31 11 64.52% 12 6 50.00%
48-
49-
// Make sure the covered branch tally for the function instantiation group is
50-
// merged to reflect maximum branch coverage of a single instantiation, just
51-
// like what is done for lines and regions. Also, the total branch tally
52-
// summary for an instantiation group should agree with the total number of
53-
// branches in the definition (In this case, 2 and 6 for func<>() and main(),
54-
// respectively). This is returned by: FunctionCoverageSummary::get(const
55-
// InstantiationGroup &Group, ...)
56-
57-
// REPORTFILE: Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover
58-
// REPORTFILE-NEXT: ---
59-
// REPORTFILE-NEXT: branch-templates.cpp 12 3 75.00% 2 0 100.00% 17 4 76.47% 8 4 50.00%
60-
// REPORTFILE-NEXT: ---
61-
// REPORTFILE-NEXT: TOTAL 12 3 75.00% 2 0 100.00% 17 4 76.47% 8 4 50.00%

llvm/tools/llvm-cov/CoverageSummaryInfo.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ FunctionCoverageSummary::get(const InstantiationGroup &Group,
100100
for (const auto &FCS : Summaries.drop_front()) {
101101
Summary.RegionCoverage.merge(FCS.RegionCoverage);
102102
Summary.LineCoverage.merge(FCS.LineCoverage);
103-
Summary.BranchCoverage.merge(FCS.BranchCoverage);
103+
104+
// Sum branch coverage across instantiation groups for the summary rather
105+
// than "merge" the maximum count. This is a clearer view into whether all
106+
// created branches are covered.
107+
Summary.BranchCoverage += FCS.BranchCoverage;
104108
}
105109
return Summary;
106110
}

llvm/tools/llvm-cov/CoverageSummaryInfo.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,6 @@ class BranchCoverageInfo {
123123
return *this;
124124
}
125125

126-
void merge(const BranchCoverageInfo &RHS) {
127-
Covered = std::max(Covered, RHS.Covered);
128-
NumBranches = std::max(NumBranches, RHS.NumBranches);
129-
}
130-
131126
size_t getCovered() const { return Covered; }
132127

133128
size_t getNumBranches() const { return NumBranches; }

0 commit comments

Comments
 (0)