From 337b0db1003578810d0d0cf345293b65e74886b7 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Thu, 7 Dec 2017 00:01:15 +0000 Subject: [Coverage] Scan ahead for the most-recent completed count (PR35495) This extends r319391. It teaches the segment builder to emit the right completed segment when more than one region ends at the same location. Fixes PR35495. llvm-svn: 319990 --- llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (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 0d52e48..ccc8cc5 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -388,11 +388,10 @@ 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]; + // Use the count from the last completed region which ends at this loc. + for (unsigned J = I + 1; J < E; ++J) + if (CompletedRegion->endLoc() == ActiveRegions[J]->endLoc()) + CompletedRegion = ActiveRegions[J]; startSegment(*CompletedRegion, CompletedSegmentLoc, false); } -- cgit v1.1