Skip to content

Commit e3df947

Browse files
committed
[llvm-cov] reset executation count to 0 after wrapped segment
Fix the bug: https://bugs.llvm.org/show_bug.cgi?id=36979. It also fixes this bug: https://bugs.llvm.org/show_bug.cgi?id=35404, which I think is caused by the same problem. Differential Revision: https://reviews.llvm.org/D85036
1 parent fe74f73 commit e3df947

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ LineCoverageStats::LineCoverageStats(
770770
ExecutionCount = WrappedSegment->Count;
771771
if (!MinRegionCount)
772772
return;
773+
ExecutionCount = 0;
773774
for (const auto *LS : LineSegments)
774775
if (isStartOfRegion(LS))
775776
ExecutionCount = std::max(ExecutionCount, LS->Count);

llvm/test/tools/llvm-cov/Inputs/instrprof-comdat.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ template <class T> T FOO<T>::DoIt(T ti) { // HEADER: [[@LINE]]| 2|template
1212
for (T I = 0; I < ti; I++) { // HEADER: [[@LINE]]| 22| for (T
1313
t += I; // HEADER: [[@LINE]]| 20| t += I;
1414
if (I > ti / 2) // HEADER: [[@LINE]]| 20| if (I > ti
15-
t -= 1; // HEADER: [[@LINE]]| 20| t -= 1;
15+
t -= 1; // HEADER: [[@LINE]]| 8| t -= 1;
1616
} // HEADER: [[@LINE]]| 20| }
1717
// HEADER: [[@LINE]]| 2|
1818
return t; // HEADER: [[@LINE]]| 2| return t;

llvm/test/tools/llvm-cov/ignore-filename-regex.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ REPORT_IGNORE_DIR-NOT: {{.*}}extra{{[/\\]}}dec.h{{.*}}
2222
REPORT_IGNORE_DIR-NOT: {{.*}}extra{{[/\\]}}inc.h{{.*}}
2323
REPORT_IGNORE_DIR: {{.*}}abs.h{{.*}}
2424
REPORT_IGNORE_DIR: {{.*}}main.cc{{.*}}
25-
REPORT_IGNORE_DIR: {{^}}TOTAL 5{{.*}}100.00%{{$}}
25+
REPORT_IGNORE_DIR: {{^}}TOTAL 5{{.*}}90.00%{{$}}
2626

2727
# Ignore all files from "extra" directory even when SOURCES specified.
2828
RUN: llvm-cov report -instr-profile %S/Inputs/sources_specified/main.profdata \
@@ -35,7 +35,7 @@ REPORT_IGNORE_DIR_WITH_SOURCES-NOT: {{.*}}extra{{[/\\]}}dec.h{{.*}}
3535
REPORT_IGNORE_DIR_WITH_SOURCES-NOT: {{.*}}extra{{[/\\]}}inc.h{{.*}}
3636
REPORT_IGNORE_DIR_WITH_SOURCES-NOT: {{.*}}main.cc{{.*}}
3737
REPORT_IGNORE_DIR_WITH_SOURCES: {{.*}}abs.h{{.*}}
38-
REPORT_IGNORE_DIR_WITH_SOURCES: {{^}}TOTAL 4{{.*}}100.00%{{$}}
38+
REPORT_IGNORE_DIR_WITH_SOURCES: {{^}}TOTAL 4{{.*}}80.00%{{$}}
3939

4040
########################
4141
# Test "show" command.

llvm/unittests/ProfileData/CoverageMappingTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ TEST_P(CoverageMappingTest, test_line_coverage_iterator) {
675675
CoverageData Data = LoadedCoverage->getCoverageForFile("file1");
676676

677677
unsigned Line = 0;
678-
unsigned LineCounts[] = {20, 20, 20, 20, 30, 10, 10, 10, 10, 0, 0};
678+
unsigned LineCounts[] = {20, 20, 20, 20, 10, 10, 10, 10, 10, 0, 0};
679679
for (const auto &LCS : getLineCoverageStats(Data)) {
680680
ASSERT_EQ(Line + 1, LCS.getLine());
681681
errs() << "Line: " << Line + 1 << ", count = " << LCS.getExecutionCount() << "\n";

0 commit comments

Comments
 (0)