From 1193b5e272db7aa969380e95503b2512d3f17270 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Mon, 4 Aug 2014 18:00:51 +0000 Subject: Coverage: add HasCodeBefore flag to a mapping region. This flag will be used by the coverage tool to help compute the execution counts for each line in a source file. Differential Revision: http://reviews.llvm.org/D4746 llvm-svn: 214740 --- llvm/lib/ProfileData/CoverageMappingReader.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'llvm/lib/ProfileData/CoverageMappingReader.cpp') diff --git a/llvm/lib/ProfileData/CoverageMappingReader.cpp b/llvm/lib/ProfileData/CoverageMappingReader.cpp index c58df0fc093..c8108d4ce99 100644 --- a/llvm/lib/ProfileData/CoverageMappingReader.cpp +++ b/llvm/lib/ProfileData/CoverageMappingReader.cpp @@ -170,13 +170,17 @@ std::error_code RawCoverageMappingReader::readMappingRegionsSubArray( } // Read the source range. - uint64_t LineStartDelta, ColumnStart, NumLines, ColumnEnd; + uint64_t LineStartDelta, CodeBeforeColumnStart, NumLines, ColumnEnd; if (auto Err = readIntMax(LineStartDelta, std::numeric_limits::max())) return Err; - if (auto Err = - readIntMax(ColumnStart, std::numeric_limits::max())) + if (auto Err = readULEB128(CodeBeforeColumnStart)) return Err; + bool HasCodeBefore = CodeBeforeColumnStart & 1; + uint64_t ColumnStart = CodeBeforeColumnStart >> + CounterMappingRegion::EncodingHasCodeBeforeBits; + if (ColumnStart > std::numeric_limits::max()) + return error(instrprof_error::malformed); if (auto Err = readIntMax(NumLines, std::numeric_limits::max())) return Err; if (auto Err = readIntMax(ColumnEnd, std::numeric_limits::max())) @@ -194,9 +198,9 @@ std::error_code RawCoverageMappingReader::readMappingRegionsSubArray( ColumnStart = 1; ColumnEnd = std::numeric_limits::max(); } - MappingRegions.push_back( - CounterMappingRegion(C, InferredFileID, LineStart, ColumnStart, - LineStart + NumLines, ColumnEnd, Kind)); + MappingRegions.push_back(CounterMappingRegion( + C, InferredFileID, LineStart, ColumnStart, LineStart + NumLines, + ColumnEnd, HasCodeBefore, Kind)); MappingRegions.back().ExpandedFileID = ExpandedFileID; } return success(); -- cgit v1.2.3