diff options
author | Vedant Kumar <vsk@apple.com> | 2017-11-30 00:28:23 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2017-11-30 00:28:23 +0000 |
commit | 80fbb85555b51fbb8c500ec13756490400191865 (patch) | |
tree | 130551fa07fa381c0b9bf9f87c973f1068c2d4cd /llvm/unittests/ProfileData | |
parent | 9e3175bb6b2c9d3d9bbb46f64c6a4e416d794e57 (diff) | |
download | bcm5719-llvm-80fbb85555b51fbb8c500ec13756490400191865.tar.gz bcm5719-llvm-80fbb85555b51fbb8c500ec13756490400191865.zip |
[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
llvm-svn: 319391
Diffstat (limited to 'llvm/unittests/ProfileData')
-rw-r--r-- | llvm/unittests/ProfileData/CoverageMappingTest.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/unittests/ProfileData/CoverageMappingTest.cpp b/llvm/unittests/ProfileData/CoverageMappingTest.cpp index 7c94ece1adc..26a8e511b4f 100644 --- a/llvm/unittests/ProfileData/CoverageMappingTest.cpp +++ b/llvm/unittests/ProfileData/CoverageMappingTest.cpp @@ -466,6 +466,32 @@ TEST_P(CoverageMappingTest, multiple_regions_end_after_parent_ends) { 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); |