diff options
Diffstat (limited to 'llvm/lib/ProfileData/Coverage')
-rw-r--r-- | llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp | 16 | ||||
-rw-r--r-- | llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp | 1 |
3 files changed, 24 insertions, 7 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp index 81e1c6bc645..4c257cf38e5 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -320,7 +320,7 @@ class SegmentBuilder { /// Emit a segment with the count from \p Region starting at \p StartLoc. // - /// \p IsRegionEntry: The segment is at the start of a new region. + /// \p IsRegionEntry: The segment is at the start of a new non-gap region. /// \p EmitSkippedRegion: The segment must be emitted as a skipped region. void startSegment(const CountedRegion &Region, LineColPair StartLoc, bool IsRegionEntry, bool EmitSkippedRegion = false) { @@ -337,7 +337,8 @@ class SegmentBuilder { if (HasCount) Segments.emplace_back(StartLoc.first, StartLoc.second, - Region.ExecutionCount, IsRegionEntry); + Region.ExecutionCount, IsRegionEntry, + Region.Kind == CounterMappingRegion::GapRegion); else Segments.emplace_back(StartLoc.first, StartLoc.second, IsRegionEntry); @@ -346,7 +347,8 @@ class SegmentBuilder { dbgs() << "Segment at " << Last.Line << ":" << Last.Col << " (count = " << Last.Count << ")" << (Last.IsRegionEntry ? ", RegionEntry" : "") - << (!Last.HasCount ? ", Skipped" : "") << "\n"; + << (!Last.HasCount ? ", Skipped" : "") + << (Last.IsGapRegion ? ", Gap" : "") << "\n"; }); } @@ -419,20 +421,22 @@ class SegmentBuilder { completeRegionsUntil(CurStartLoc, FirstCompletedRegion); } + bool GapRegion = CR.value().Kind == CounterMappingRegion::GapRegion; + // Try to emit a segment for the current region. 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(); startSegment(ActiveRegions.empty() ? CR.value() : *ActiveRegions.back(), - CurStartLoc, true, Skipped); + CurStartLoc, !GapRegion, Skipped); continue; } if (CR.index() + 1 == Regions.size() || CurStartLoc != Regions[CR.index() + 1].startLoc()) { // Emit a segment if the next region doesn't start at the same location // as this one. - startSegment(CR.value(), CurStartLoc, true); + startSegment(CR.value(), CurStartLoc, !GapRegion); } // This region is active (i.e not completed). diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp index 9bf70c2e3aa..467a36ca748 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp @@ -216,6 +216,13 @@ Error RawCoverageMappingReader::readMappingRegionsSubArray( if (auto Err = readIntMax(ColumnEnd, std::numeric_limits<unsigned>::max())) return Err; LineStart += LineStartDelta; + + // If the high bit of ColumnEnd is set, this is a gap region. + if (ColumnEnd & (1U << 31)) { + Kind = CounterMappingRegion::GapRegion; + ColumnEnd &= ~(1U << 31); + } + // Adjust the column locations for the empty regions that are supposed to // cover whole lines. Those regions should be encoded with the // column range (1 -> std::numeric_limits<unsigned>::max()), but because @@ -534,11 +541,16 @@ Expected<std::unique_ptr<CovMapFuncRecordReader>> CovMapFuncRecordReader::get( return llvm::make_unique<VersionedCovMapFuncRecordReader< CovMapVersion::Version1, IntPtrT, Endian>>(P, R, F); case CovMapVersion::Version2: + case CovMapVersion::Version3: // Decompress the name data. if (Error E = P.create(P.getNameData())) return std::move(E); - return llvm::make_unique<VersionedCovMapFuncRecordReader< - CovMapVersion::Version2, IntPtrT, Endian>>(P, R, F); + if (Version == CovMapVersion::Version2) + return llvm::make_unique<VersionedCovMapFuncRecordReader< + CovMapVersion::Version2, IntPtrT, Endian>>(P, R, F); + else + return llvm::make_unique<VersionedCovMapFuncRecordReader< + CovMapVersion::Version3, IntPtrT, Endian>>(P, R, F); } llvm_unreachable("Unsupported version"); } diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp index 4a1ce16c486..49e82e48105 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp @@ -171,6 +171,7 @@ void CoverageMappingWriter::write(raw_ostream &OS) { Counter Count = Minimizer.adjust(I->Count); switch (I->Kind) { case CounterMappingRegion::CodeRegion: + case CounterMappingRegion::GapRegion: writeCounter(MinExpressions, Count, OS); break; case CounterMappingRegion::ExpansionRegion: { |