diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -794,7 +794,6 @@ 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 --- a/llvm/test/tools/llvm-cov/Inputs/instrprof-comdat.h +++ b/llvm/test/tools/llvm-cov/Inputs/instrprof-comdat.h @@ -12,7 +12,7 @@ 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]]| 8| t -= 1; + t -= 1; // HEADER: [[@LINE]]| 20| t -= 1; } // HEADER: [[@LINE]]| 20| } // HEADER: [[@LINE]]| 2| return t; // HEADER: [[@LINE]]| 2| return t; diff --git a/llvm/test/tools/llvm-cov/branch-c-general.test b/llvm/test/tools/llvm-cov/branch-c-general.test --- a/llvm/test/tools/llvm-cov/branch-c-general.test +++ b/llvm/test/tools/llvm-cov/branch-c-general.test @@ -118,18 +118,18 @@ // REPORT-NEXT: --- // REPORT-NEXT: simple_loops 8 0 100.00% 9 0 100.00% 6 0 100.00% // REPORT-NEXT: conditionals 24 0 100.00% 15 0 100.00% 16 2 87.50% -// REPORT-NEXT: early_exits 20 4 80.00% 25 3 88.00% 16 6 62.50% -// REPORT-NEXT: jumps 39 12 69.23% 48 4 91.67% 26 9 65.38% -// REPORT-NEXT: switches 28 5 82.14% 38 5 86.84% 30 9 70.00% +// REPORT-NEXT: early_exits 20 4 80.00% 25 2 92.00% 16 6 62.50% +// REPORT-NEXT: jumps 39 12 69.23% 48 2 95.83% 26 9 65.38% +// REPORT-NEXT: switches 28 5 82.14% 38 4 89.47% 30 9 70.00% // REPORT-NEXT: big_switch 25 1 96.00% 32 0 100.00% 30 6 80.00% // REPORT-NEXT: boolean_operators 16 0 100.00% 13 0 100.00% 22 2 90.91% // REPORT-NEXT: boolop_loops 19 0 100.00% 14 0 100.00% 16 2 87.50% -// REPORT-NEXT: conditional_operator 4 2 50.00% 8 1 87.50% 4 2 50.00% +// REPORT-NEXT: conditional_operator 4 2 50.00% 8 0 100.00% 4 2 50.00% // REPORT-NEXT: do_fallthrough 9 0 100.00% 12 0 100.00% 6 0 100.00% // REPORT-NEXT: main 1 0 100.00% 16 0 100.00% 0 0 0.00% // REPORT-NEXT: c-general.c:static_func 4 0 100.00% 4 0 100.00% 2 0 100.00% // REPORT-NEXT: --- -// REPORT-NEXT: TOTAL 197 24 87.82% 234 13 94.44% 174 38 78.16% +// REPORT-NEXT: TOTAL 197 24 87.82% 234 8 96.58% 174 38 78.16% // Test file-level report. // RUN: llvm-profdata merge %S/Inputs/branch-c-general.proftext -o %t.profdata @@ -157,7 +157,7 @@ // HTML-INDEX: // HTML-INDEX: 100.00% (12/12) // HTML-INDEX: -// HTML-INDEX: 94.44% (221/234) +// HTML-INDEX: 96.58% (226/234) // HTML-INDEX: // HTML-INDEX: 87.82% (173/197) // HTML-INDEX: diff --git a/llvm/test/tools/llvm-cov/branch-logical-mixed.cpp b/llvm/test/tools/llvm-cov/branch-logical-mixed.cpp --- a/llvm/test/tools/llvm-cov/branch-logical-mixed.cpp +++ b/llvm/test/tools/llvm-cov/branch-logical-mixed.cpp @@ -84,7 +84,7 @@ // REPORT: Name Regions Miss Cover Lines Miss Cover Branches Miss Cover // REPORT-NEXT: --- -// REPORT-NEXT: _Z4funcii 77 9 88.31% 68 10 85.29% 80 32 60.00% +// REPORT-NEXT: _Z4funcii 77 9 88.31% 68 3 95.59% 80 32 60.00% // REPORT-NEXT: main 1 0 100.00% 5 0 100.00% 0 0 0.00% // REPORT-NEXT: --- -// REPORT-NEXT: TOTAL 78 9 88.46% 73 10 86.30% 80 32 60.00% +// REPORT-NEXT: TOTAL 78 9 88.46% 73 3 95.89% 80 32 60.00% diff --git a/llvm/test/tools/llvm-cov/branch-noShowBranch.test b/llvm/test/tools/llvm-cov/branch-noShowBranch.test --- a/llvm/test/tools/llvm-cov/branch-noShowBranch.test +++ b/llvm/test/tools/llvm-cov/branch-noShowBranch.test @@ -20,6 +20,6 @@ // REPORT-NOT: do_fallthrough 9 0 100.00% 12 0 100.00% 6 0 100.00% // REPORT-NOT: main 1 0 100.00% 16 0 100.00% 0 0 0.00% // REPORT-NOT: c-general.c:static_func 4 0 100.00% 4 0 100.00% 2 0 100.00% -// REPORT: TOTAL 197 24 87.82% 234 13 94.44% +// REPORT: TOTAL 197 24 87.82% 234 8 96.58% // REPORT-NOT: TOTAL 197 24 87.82% 234 13 94.44% 174 38 78.16% diff --git a/llvm/test/tools/llvm-cov/ignore-filename-regex.test b/llvm/test/tools/llvm-cov/ignore-filename-regex.test --- 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{{[/\\]}}inc.h{{.*}} REPORT_IGNORE_DIR: {{.*}}abs.h{{.*}} REPORT_IGNORE_DIR: {{.*}}main.cc{{.*}} -REPORT_IGNORE_DIR: {{^}}TOTAL 5{{.*}}90.00%{{$}} +REPORT_IGNORE_DIR: {{^}}TOTAL 5{{.*}}100.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{{[/\\]}}inc.h{{.*}} REPORT_IGNORE_DIR_WITH_SOURCES-NOT: {{.*}}main.cc{{.*}} REPORT_IGNORE_DIR_WITH_SOURCES: {{.*}}abs.h{{.*}} -REPORT_IGNORE_DIR_WITH_SOURCES: {{^}}TOTAL 4{{.*}}80.00%{{$}} +REPORT_IGNORE_DIR_WITH_SOURCES: {{^}}TOTAL 4{{.*}}100.00%{{$}} ######################## # Test "show" command. diff --git a/llvm/unittests/ProfileData/CoverageMappingTest.cpp b/llvm/unittests/ProfileData/CoverageMappingTest.cpp --- a/llvm/unittests/ProfileData/CoverageMappingTest.cpp +++ b/llvm/unittests/ProfileData/CoverageMappingTest.cpp @@ -680,7 +680,7 @@ CoverageData Data = LoadedCoverage->getCoverageForFile("file1"); unsigned Line = 0; - unsigned LineCounts[] = {20, 20, 20, 20, 10, 10, 10, 10, 10, 0, 0}; + unsigned LineCounts[] = {20, 20, 20, 20, 30, 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";