[llvm] e3df947 - [llvm-cov] reset executation count to 0 after wrapped segment
Zequan Wu via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 4 18:39:00 PDT 2020
Author: Zequan Wu
Date: 2020-08-04T18:38:44-07:00
New Revision: e3df9471750935876bd2bf7da93ccf0eacca8592
URL: https://github.com/llvm/llvm-project/commit/e3df9471750935876bd2bf7da93ccf0eacca8592
DIFF: https://github.com/llvm/llvm-project/commit/e3df9471750935876bd2bf7da93ccf0eacca8592.diff
LOG: [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
Added:
Modified:
llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
llvm/test/tools/llvm-cov/Inputs/instrprof-comdat.h
llvm/test/tools/llvm-cov/ignore-filename-regex.test
llvm/unittests/ProfileData/CoverageMappingTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 70f00d333db1..3197f5d1a3d9 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -770,6 +770,7 @@ LineCoverageStats::LineCoverageStats(
ExecutionCount = WrappedSegment->Count;
if (!MinRegionCount)
return;
+ ExecutionCount = 0;
for (const auto *LS : LineSegments)
if (isStartOfRegion(LS))
ExecutionCount = std::max(ExecutionCount, LS->Count);
diff --git a/llvm/test/tools/llvm-cov/Inputs/instrprof-comdat.h b/llvm/test/tools/llvm-cov/Inputs/instrprof-comdat.h
index 07941f9bb497..d224fd0d00ea 100644
--- a/llvm/test/tools/llvm-cov/Inputs/instrprof-comdat.h
+++ b/llvm/test/tools/llvm-cov/Inputs/instrprof-comdat.h
@@ -12,7 +12,7 @@ template <class T> T FOO<T>::DoIt(T ti) { // HEADER: [[@LINE]]| 2|template
for (T I = 0; I < ti; I++) { // HEADER: [[@LINE]]| 22| for (T
t += I; // HEADER: [[@LINE]]| 20| t += I;
if (I > ti / 2) // HEADER: [[@LINE]]| 20| if (I > ti
- t -= 1; // HEADER: [[@LINE]]| 20| t -= 1;
+ t -= 1; // HEADER: [[@LINE]]| 8| t -= 1;
} // HEADER: [[@LINE]]| 20| }
// HEADER: [[@LINE]]| 2|
return t; // HEADER: [[@LINE]]| 2| return t;
diff --git a/llvm/test/tools/llvm-cov/ignore-filename-regex.test b/llvm/test/tools/llvm-cov/ignore-filename-regex.test
index b8c15da281c1..0824645b5082 100644
--- a/llvm/test/tools/llvm-cov/ignore-filename-regex.test
+++ b/llvm/test/tools/llvm-cov/ignore-filename-regex.test
@@ -22,7 +22,7 @@ REPORT_IGNORE_DIR-NOT: {{.*}}extra{{[/\\]}}dec.h{{.*}}
REPORT_IGNORE_DIR-NOT: {{.*}}extra{{[/\\]}}inc.h{{.*}}
REPORT_IGNORE_DIR: {{.*}}abs.h{{.*}}
REPORT_IGNORE_DIR: {{.*}}main.cc{{.*}}
-REPORT_IGNORE_DIR: {{^}}TOTAL 5{{.*}}100.00%{{$}}
+REPORT_IGNORE_DIR: {{^}}TOTAL 5{{.*}}90.00%{{$}}
# Ignore all files from "extra" directory even when SOURCES specified.
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{{.*}}
REPORT_IGNORE_DIR_WITH_SOURCES-NOT: {{.*}}extra{{[/\\]}}inc.h{{.*}}
REPORT_IGNORE_DIR_WITH_SOURCES-NOT: {{.*}}main.cc{{.*}}
REPORT_IGNORE_DIR_WITH_SOURCES: {{.*}}abs.h{{.*}}
-REPORT_IGNORE_DIR_WITH_SOURCES: {{^}}TOTAL 4{{.*}}100.00%{{$}}
+REPORT_IGNORE_DIR_WITH_SOURCES: {{^}}TOTAL 4{{.*}}80.00%{{$}}
########################
# Test "show" command.
diff --git a/llvm/unittests/ProfileData/CoverageMappingTest.cpp b/llvm/unittests/ProfileData/CoverageMappingTest.cpp
index 4854b7f1454c..43386d23883e 100644
--- a/llvm/unittests/ProfileData/CoverageMappingTest.cpp
+++ b/llvm/unittests/ProfileData/CoverageMappingTest.cpp
@@ -675,7 +675,7 @@ TEST_P(CoverageMappingTest, test_line_coverage_iterator) {
CoverageData Data = LoadedCoverage->getCoverageForFile("file1");
unsigned Line = 0;
- unsigned LineCounts[] = {20, 20, 20, 20, 30, 10, 10, 10, 10, 0, 0};
+ unsigned LineCounts[] = {20, 20, 20, 20, 10, 10, 10, 10, 10, 0, 0};
for (const auto &LCS : getLineCoverageStats(Data)) {
ASSERT_EQ(Line + 1, LCS.getLine());
errs() << "Line: " << Line + 1 << ", count = " << LCS.getExecutionCount() << "\n";
More information about the llvm-commits
mailing list