From 80fbb85555b51fbb8c500ec13756490400191865 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Thu, 30 Nov 2017 00:28:23 +0000 Subject: [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 --- llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp') diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp index 6cde386..0d52e48 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -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); } -- cgit v1.1