aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
diff options
context:
space:
mode:
authorZequan Wu <zequanwu@google.com>2020-09-02 14:50:32 -0700
committerZequan Wu <zequanwu@google.com>2020-09-21 12:42:53 -0700
commit9caa3fbe03f43e3eec30262fbba87c1ee15c05a3 (patch)
treee49540c6b7eb9cfc0566cab2b5b84b03195c735e /llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
parent6bad3caeb079748a25fd34bd21255824c8dcb8f1 (diff)
downloadllvm-9caa3fbe03f43e3eec30262fbba87c1ee15c05a3.zip
llvm-9caa3fbe03f43e3eec30262fbba87c1ee15c05a3.tar.gz
llvm-9caa3fbe03f43e3eec30262fbba87c1ee15c05a3.tar.bz2
[Coverage] Add empty line regions to SkippedRegions
Differential Revision: https://reviews.llvm.org/D84988
Diffstat (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp')
-rw-r--r--llvm/lib/ProfileData/Coverage/CoverageMapping.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 3197f5d..ec840a3 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -485,9 +485,15 @@ class SegmentBuilder {
if (CurStartLoc == CR.value().endLoc()) {
// Avoid making zero-length regions active. If it's the last region,
// emit a skipped segment. Otherwise use its predecessor's count.
- const bool Skipped = (CR.index() + 1) == Regions.size();
+ const bool Skipped =
+ (CR.index() + 1) == Regions.size() ||
+ CR.value().Kind == CounterMappingRegion::SkippedRegion;
startSegment(ActiveRegions.empty() ? CR.value() : *ActiveRegions.back(),
CurStartLoc, !GapRegion, Skipped);
+ // If it is skipped segment, create a segment with last pushed
+ // regions's count at CurStartLoc.
+ if (Skipped && !ActiveRegions.empty())
+ startSegment(*ActiveRegions.back(), CurStartLoc, false);
continue;
}
if (CR.index() + 1 == Regions.size() ||
@@ -587,6 +593,8 @@ public:
const auto &L = Segments[I - 1];
const auto &R = Segments[I];
if (!(L.Line < R.Line) && !(L.Line == R.Line && L.Col < R.Col)) {
+ if (L.Line == R.Line && L.Col == R.Col && !L.HasCount)
+ continue;
LLVM_DEBUG(dbgs() << " ! Segment " << L.Line << ":" << L.Col
<< " followed by " << R.Line << ":" << R.Col << "\n");
assert(false && "Coverage segments not unique or sorted");