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