[llvm] r319391 - [Coverage] Use the most-recent completed region count (PR35437)
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 29 16:31:28 PST 2017
Apologies, this commit title is incorrect. This is a fix for llvm.org/PR35426 <http://llvm.org/PR35426>, not PR35437.
vedant
> On Nov 29, 2017, at 4:28 PM, Vedant Kumar via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>
> Author: vedantk
> Date: Wed Nov 29 16:28:23 2017
> New Revision: 319391
>
> URL: http://llvm.org/viewvc/llvm-project?rev=319391&view=rev
> Log:
> [Coverage] Use the most-recent completed region count (PR35437)
>
> This is a fix for the coverage segment builder.
>
> If multiple regions must be popped off the active stack at once, and
> more than one of them end at the same location, emit a segment using the
> count from the most-recent completed region.
>
> Fixes PR35437, rdar://35760630
>
> Testing: invoked llvm-cov on a stage2 build of clang, additional unit
> tests, check-profile
>
> Modified:
> llvm/trunk/lib/ProfileData/Coverage/CoverageMapping.cpp
> llvm/trunk/test/tools/llvm-cov/deferred-region.cpp
> llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp
>
> Modified: llvm/trunk/lib/ProfileData/Coverage/CoverageMapping.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/Coverage/CoverageMapping.cpp?rev=319391&r1=319390&r2=319391&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ProfileData/Coverage/CoverageMapping.cpp (original)
> +++ llvm/trunk/lib/ProfileData/Coverage/CoverageMapping.cpp Wed Nov 29 16:28:23 2017
> @@ -388,6 +388,12 @@ class SegmentBuilder {
> if (CompletedSegmentLoc == CompletedRegion->endLoc())
> continue;
>
> + // Use the count from the next completed region if it ends at the same
> + // location.
> + if (I + 1 < E &&
> + CompletedRegion->endLoc() == ActiveRegions[I + 1]->endLoc())
> + CompletedRegion = ActiveRegions[I + 1];
> +
> startSegment(*CompletedRegion, CompletedSegmentLoc, false);
> }
>
>
> Modified: llvm/trunk/test/tools/llvm-cov/deferred-region.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/deferred-region.cpp?rev=319391&r1=319390&r2=319391&view=diff
> ==============================================================================
> --- llvm/trunk/test/tools/llvm-cov/deferred-region.cpp (original)
> +++ llvm/trunk/test/tools/llvm-cov/deferred-region.cpp Wed Nov 29 16:28:23 2017
> @@ -45,7 +45,7 @@ void while_loop() {
> break; // CHECK: [[@LINE]]|{{ +}}1|
> // CHECK: [[@LINE]]|{{ +}}0|
> while (++x < 5) {} // CHECK: [[@LINE]]|{{ +}}0|
> - } // CHECK: [[@LINE]]|{{ +}}1|
> + } // CHECK: [[@LINE]]|{{ +}}0|
>
> if (x == 0) // CHECK: [[@LINE]]|{{ +}}1|
> throw Error(); // CHECK: [[@LINE]]|{{ +}}0|
> @@ -97,6 +97,8 @@ int main() {
> // MARKER-NEXT: Highlighted line 47, 14 -> 21
> // MARKER-NEXT: Highlighted line 47, 21 -> 23
> // MARKER-NEXT: Highlighted line 47, 23 -> 25
> +// MARKER-NEXT: Highlighted line 47, 25 -> ?
> +// MARKER-NEXT: Highlighted line 48, 1 -> 6
> // MARKER-NEXT: Highlighted line 51, 7 -> 20
> // MARKER-NEXT: Marker at 53:5 = 1
> // MARKER-NEXT: Highlighted line 55, 9 -> 14
>
> Modified: llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp?rev=319391&r1=319390&r2=319391&view=diff
> ==============================================================================
> --- llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp (original)
> +++ llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp Wed Nov 29 16:28:23 2017
> @@ -466,6 +466,32 @@ TEST_P(CoverageMappingTest, multiple_reg
> EXPECT_EQ(CoverageSegment(9, 9, false), Segments[7]);
> }
>
> +TEST_P(CoverageMappingTest, multiple_completed_segments_at_same_loc) {
> + ProfileWriter.addRecord({"func1", 0x1234, {0, 1, 2}}, Err);
> + startFunction("func1", 0x1234);
> +
> + // PR35437
> + addCMR(Counter::getCounter(1), "file1", 2, 1, 18, 2);
> + addCMR(Counter::getCounter(0), "file1", 8, 12, 14, 6);
> + addCMR(Counter::getCounter(1), "file1", 9, 1, 14, 6);
> + addCMR(Counter::getCounter(2), "file1", 11, 13, 11, 14);
> +
> + EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());
> + const auto FunctionRecords = LoadedCoverage->getCoveredFunctions();
> + const auto &FunctionRecord = *FunctionRecords.begin();
> + CoverageData Data = LoadedCoverage->getCoverageForFunction(FunctionRecord);
> + std::vector<CoverageSegment> Segments(Data.begin(), Data.end());
> +
> + ASSERT_EQ(6U, Segments.size());
> + EXPECT_EQ(CoverageSegment(2, 1, 1, true), Segments[0]);
> + EXPECT_EQ(CoverageSegment(8, 12, 0, true), Segments[1]);
> + EXPECT_EQ(CoverageSegment(9, 1, 1, true), Segments[2]);
> + EXPECT_EQ(CoverageSegment(11, 13, 2, true), Segments[3]);
> + // Use count=1 (from 9:1 -> 14:6), not count=0 (from 8:12 -> 14:6).
> + EXPECT_EQ(CoverageSegment(11, 14, 1, false), Segments[4]);
> + EXPECT_EQ(CoverageSegment(18, 2, false), Segments[5]);
> +}
> +
> TEST_P(CoverageMappingTest, dont_emit_redundant_segments) {
> ProfileWriter.addRecord({"func1", 0x1234, {1, 1}}, Err);
> startFunction("func1", 0x1234);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171129/921f666a/attachment.html>
More information about the llvm-commits
mailing list