diff options
author | Zequan Wu <zequanwu@google.com> | 2020-09-02 14:50:32 -0700 |
---|---|---|
committer | Zequan Wu <zequanwu@google.com> | 2020-09-21 12:42:53 -0700 |
commit | 9caa3fbe03f43e3eec30262fbba87c1ee15c05a3 (patch) | |
tree | e49540c6b7eb9cfc0566cab2b5b84b03195c735e /llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | |
parent | 6bad3caeb079748a25fd34bd21255824c8dcb8f1 (diff) | |
download | llvm-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.cpp | 10 |
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"); |