Skip to content

Commit 92bf1c1

Browse files
committed
llvm-cov: Emit RegionCoverage based on CoverageData::Segments
1 parent f86c537 commit 92bf1c1

File tree

8 files changed

+31
-32
lines changed

8 files changed

+31
-32
lines changed

llvm/test/tools/llvm-cov/branch-c-general.test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,19 @@
117117
// REPORT: Name Regions Miss Cover Lines Miss Cover Branches Miss Cover
118118
// REPORT-NEXT: ---
119119
// REPORT-NEXT: simple_loops 8 0 100.00% 9 0 100.00% 6 0 100.00%
120-
// REPORT-NEXT: conditionals 24 0 100.00% 15 0 100.00% 16 2 87.50%
120+
// REPORT-NEXT: conditionals 22 0 100.00% 15 0 100.00% 16 2 87.50%
121121
// REPORT-NEXT: early_exits 20 4 80.00% 25 2 92.00% 16 6 62.50%
122122
// REPORT-NEXT: jumps 39 12 69.23% 48 2 95.83% 26 9 65.38%
123-
// REPORT-NEXT: switches 28 5 82.14% 38 4 89.47% 28 7 75.00%
123+
// REPORT-NEXT: switches 27 4 85.19% 38 4 89.47% 28 7 75.00%
124124
// REPORT-NEXT: big_switch 25 1 96.00% 32 0 100.00% 30 6 80.00%
125-
// REPORT-NEXT: boolean_operators 16 0 100.00% 13 0 100.00% 22 2 90.91%
126-
// REPORT-NEXT: boolop_loops 19 0 100.00% 14 0 100.00% 16 2 87.50%
125+
// REPORT-NEXT: boolean_operators 14 0 100.00% 13 0 100.00% 22 2 90.91%
126+
// REPORT-NEXT: boolop_loops 15 0 100.00% 14 0 100.00% 16 2 87.50%
127127
// REPORT-NEXT: conditional_operator 4 2 50.00% 8 0 100.00% 4 2 50.00%
128128
// REPORT-NEXT: do_fallthrough 9 0 100.00% 12 0 100.00% 6 0 100.00%
129129
// REPORT-NEXT: main 1 0 100.00% 16 0 100.00% 0 0 0.00%
130130
// REPORT-NEXT: c-general.c:static_func 4 0 100.00% 4 0 100.00% 2 0 100.00%
131131
// REPORT-NEXT: ---
132-
// REPORT-NEXT: TOTAL 197 24 87.82% 234 8 96.58% 172 36 79.07%
132+
// REPORT-NEXT: TOTAL 188 23 87.77% 234 8 96.58% 172 36 79.07%
133133

134134
// Test file-level report.
135135
// RUN: llvm-profdata merge %S/Inputs/branch-c-general.proftext -o %t.profdata
@@ -159,7 +159,7 @@
159159
// HTML-INDEX: <td class='column-entry-yellow'>
160160
// HTML-INDEX: 96.58% (226/234)
161161
// HTML-INDEX: <td class='column-entry-yellow'>
162-
// HTML-INDEX: 87.82% (173/197)
162+
// HTML-INDEX: 87.77% (165/188)
163163
// HTML-INDEX: <td class='column-entry-red'>
164164
// HTML-INDEX: 79.07% (136/172)
165165
// HTML-INDEX: <tr class='light-row-bold'>

llvm/test/tools/llvm-cov/branch-export-json.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// CHECK: 45,5,45,11,0,5,0,0,4
1919
// CHECK: 47,5,47,12,3,2,0,0,4
2020
// CHECK: 53,12,53,20,50,5,0,0,4
21-
// CHECK: {"count":30,"covered":26,"notcovered":4,"percent":86.666666666666671}
21+
// CHECK: {"count":30,"covered":26,"notcovered":4,"percent":86.6[[#]]}
2222

2323
// Check recursive macro-expansions.
2424
// RUN: llvm-profdata merge %S/Inputs/branch-macros.proftext -o %t.profdata

llvm/test/tools/llvm-cov/branch-macros.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
// REPORT: Name Regions Miss Cover Lines Miss Cover Branches Miss Cover
1010
// REPORT-NEXT: ---
11-
// REPORT-NEXT: _Z4funcii 28 4 85.71% 18 0 100.00% 30 14 53.33%
12-
// REPORT-NEXT: _Z5func2ii 13 1 92.31% 8 0 100.00% 10 2 80.00%
11+
// REPORT-NEXT: _Z4funcii 12 4 66.67% 18 0 100.00% 30 14 53.33%
12+
// REPORT-NEXT: _Z5func2ii 3 0 100.00% 8 0 100.00% 10 2 80.00%
1313
// REPORT-NEXT: main 1 0 100.00% 6 0 100.00% 0 0 0.00%
1414
// REPORT-NEXT: ---
15-
// REPORT-NEXT: TOTAL 42 5 88.10% 32 0 100.00% 40 16 60.00%
15+
// REPORT-NEXT: TOTAL 16 4 75.00% 32 0 100.00% 40 16 60.00%

llvm/test/tools/llvm-cov/branch-noShowBranch.test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
// REPORT-NOT: Name Regions Miss Cover Lines Miss Cover Branches Miss Cover
1010
// REPORT: ---
1111
// REPORT-NOT: simple_loops 8 0 100.00% 9 0 100.00% 6 0 100.00%
12-
// REPORT-NOT: conditionals 24 0 100.00% 15 0 100.00% 16 2 87.50%
12+
// REPORT-NOT: conditionals 22 0 100.00% 15 0 100.00% 16 2 87.50%
1313
// REPORT-NOT: early_exits 20 4 80.00% 25 2 92.00% 16 6 62.50%
1414
// REPORT-NOT: jumps 39 12 69.23% 48 2 95.83% 26 9 65.38%
15-
// REPORT-NOT: switches 28 5 82.14% 38 4 89.47% 28 7 75.00%
15+
// REPORT-NOT: switches 27 4 85.19% 38 4 89.47% 28 7 75.00%
1616
// REPORT-NOT: big_switch 25 1 96.00% 32 0 100.00% 30 6 80.00%
17-
// REPORT-NOT: boolean_operators 16 0 100.00% 13 0 100.00% 22 2 90.91%
18-
// REPORT-NOT: boolop_loops 19 0 100.00% 14 0 100.00% 16 2 87.50%
17+
// REPORT-NOT: boolean_operators 14 0 100.00% 13 0 100.00% 22 2 90.91%
18+
// REPORT-NOT: boolop_loops 15 0 100.00% 14 0 100.00% 16 2 87.50%
1919
// REPORT-NOT: conditional_operator 4 2 50.00% 8 0 100.00% 4 2 50.00%
2020
// REPORT-NOT: do_fallthrough 9 0 100.00% 12 0 100.00% 6 0 100.00%
2121
// REPORT-NOT: main 1 0 100.00% 16 0 100.00% 0 0 0.00%
2222
// REPORT-NOT: c-general.c:static_func 4 0 100.00% 4 0 100.00% 2 0 100.00%
23-
// REPORT: TOTAL 197 24 87.82% 234 8 96.58%
24-
// REPORT-NOT: TOTAL 197 24 87.82% 234 8 96.58% 172 36 79.07%
23+
// REPORT: TOTAL 188 23 87.77% 234 8 96.58%
24+
// REPORT-NOT: TOTAL 188 23 87.77% 234 8 96.58% 172 36 79.07%

llvm/test/tools/llvm-cov/mcdc-general-none.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434

3535
// REPORT: Name Regions Miss Cover Lines Miss Cover Branches Miss Cover MC/DC Conditions Miss Cover
3636
// REPORT-NEXT: -------------------------------------------------------------------------------------------------------------------------------------------
37-
// REPORT-NEXT: _Z4testbbbb 25 0 100.00% 9 0 100.00% 24 2 91.67% 12 12 0.00%
37+
// REPORT-NEXT: _Z4testbbbb 21 0 100.00% 9 0 100.00% 24 2 91.67% 12 12 0.00%
3838
// REPORT-NEXT: main 1 0 100.00% 11 0 100.00% 0 0 0.00% 0 0 0.00%
3939
// REPORT-NEXT: ---
40-
// REPORT-NEXT: TOTAL 26 0 100.00% 20 0 100.00% 24 2 91.67% 12 12 0.00%
40+
// REPORT-NEXT: TOTAL 22 0 100.00% 20 0 100.00% 24 2 91.67% 12 12 0.00%
4141

4242
// Turn off MC/DC summary.
4343
// RUN: llvm-cov report %S/Inputs/mcdc-general.o -instr-profile %t.profdata -show-functions -path-equivalence=.,%S/Inputs %S/Inputs/mcdc-general.cpp | FileCheck %s -check-prefix=REPORT_NOMCDC
@@ -67,7 +67,7 @@
6767
// HTML-INDEX: <td class='column-entry-green'>
6868
// HTML-INDEX: 100.00% (2/2)
6969
// HTML-INDEX: 100.00% (20/20)
70-
// HTML-INDEX: 100.00% (26/26)
70+
// HTML-INDEX: 100.00% (22/22)
7171
// HTML-INDEX: 91.67% (22/24)
7272
// HTML-INDEX: 0.00% (0/12)
7373
// HTML-INDEX: Totals

llvm/test/tools/llvm-cov/mcdc-general.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@
100100

101101
// REPORT: Name Regions Miss Cover Lines Miss Cover Branches Miss Cover MC/DC Conditions Miss Cover
102102
// REPORT-NEXT: -------------------------------------------------------------------------------------------------------------------------------------------
103-
// REPORT-NEXT: _Z4testbbbb 25 0 100.00% 9 0 100.00% 24 2 91.67% 12 2 83.33%
103+
// REPORT-NEXT: _Z4testbbbb 21 0 100.00% 9 0 100.00% 24 2 91.67% 12 2 83.33%
104104
// REPORT-NEXT: main 1 0 100.00% 11 0 100.00% 0 0 0.00% 0 0 0.00%
105105
// REPORT-NEXT: ---
106-
// REPORT-NEXT: TOTAL 26 0 100.00% 20 0 100.00% 24 2 91.67% 12 2 83.33%
106+
// REPORT-NEXT: TOTAL 22 0 100.00% 20 0 100.00% 24 2 91.67% 12 2 83.33%
107107

108108
// Turn off MC/DC summary.
109109
// RUN: llvm-cov report %S/Inputs/mcdc-general.o -instr-profile %t.profdata -show-functions -path-equivalence=.,%S/Inputs %S/Inputs/mcdc-general.cpp | FileCheck %s -check-prefix=REPORT_NOMCDC
@@ -133,7 +133,7 @@
133133
// HTML-INDEX: <td class='column-entry-green'>
134134
// HTML-INDEX: 100.00% (2/2)
135135
// HTML-INDEX: 100.00% (20/20)
136-
// HTML-INDEX: 100.00% (26/26)
136+
// HTML-INDEX: 100.00% (22/22)
137137
// HTML-INDEX: 91.67% (22/24)
138138
// HTML-INDEX: 83.33% (10/12)
139139
// HTML-INDEX: Totals

llvm/tools/llvm-cov/CoverageSummaryInfo.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ auto sumMCDCPairs(const ArrayRef<MCDCRecord> &Records) {
6363
}
6464

6565
static std::pair<RegionCoverageInfo, LineCoverageInfo>
66-
sumRegions(ArrayRef<CountedRegion> CodeRegions, const CoverageData &CD) {
66+
sumRegions(const CoverageData &CD) {
6767
// Compute the region coverage.
6868
size_t NumCodeRegions = 0, CoveredRegions = 0;
69-
for (auto &CR : CodeRegions) {
70-
if (CR.Kind != CounterMappingRegion::CodeRegion)
69+
for (auto I = CD.begin(), E = CD.end(); I != E; ++I) {
70+
if (!I->IsRegionEntry || !I->HasCount || I->IsGapRegion)
7171
continue;
72+
7273
++NumCodeRegions;
73-
if (CR.ExecutionCount != 0)
74+
if (I->Count)
7475
++CoveredRegions;
7576
}
7677

@@ -88,9 +89,8 @@ sumRegions(ArrayRef<CountedRegion> CodeRegions, const CoverageData &CD) {
8889
LineCoverageInfo(CoveredLines, NumLines)};
8990
}
9091

91-
CoverageDataSummary::CoverageDataSummary(const CoverageData &CD,
92-
ArrayRef<CountedRegion> CodeRegions) {
93-
std::tie(RegionCoverage, LineCoverage) = sumRegions(CodeRegions, CD);
92+
CoverageDataSummary::CoverageDataSummary(const CoverageData &CD) {
93+
std::tie(RegionCoverage, LineCoverage) = sumRegions(CD);
9494
BranchCoverage = sumBranches(CD.getBranches());
9595
MCDCCoverage = sumMCDCPairs(CD.getMCDCRecords());
9696
}
@@ -103,7 +103,7 @@ FunctionCoverageSummary::get(const CoverageMapping &CM,
103103
auto Summary =
104104
FunctionCoverageSummary(Function.Name, Function.ExecutionCount);
105105

106-
Summary += CoverageDataSummary(CD, Function.CountedRegions);
106+
Summary += CoverageDataSummary(CD);
107107

108108
// Compute the branch coverage, including branches from expansions.
109109
Summary.BranchCoverage += sumBranchExpansions(CM, CD.getExpansions());

llvm/tools/llvm-cov/CoverageSummaryInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ struct CoverageDataSummary {
230230
MCDCCoverageInfo MCDCCoverage;
231231

232232
CoverageDataSummary() = default;
233-
CoverageDataSummary(const coverage::CoverageData &CD,
234-
ArrayRef<coverage::CountedRegion> CodeRegions);
233+
CoverageDataSummary(const coverage::CoverageData &CD);
235234

236235
auto &operator+=(const CoverageDataSummary &RHS) {
237236
RegionCoverage += RHS.RegionCoverage;

0 commit comments

Comments
 (0)