X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FProfileData%2FCoverageMappingReader.cpp;h=c8108d4ce9945e9759c38c71e0559261cff5d3ff;hb=8841fb5f25d959dd938b4a523f2c1672fa49bdbd;hp=21acae1bbdd3aaf993e8003e1e346b2dceb64a77;hpb=b3a3e591cafb4fd2137624ed00a3248e39ce6055;p=oota-llvm.git diff --git a/lib/ProfileData/CoverageMappingReader.cpp b/lib/ProfileData/CoverageMappingReader.cpp index 21acae1bbdd..c8108d4ce99 100644 --- a/lib/ProfileData/CoverageMappingReader.cpp +++ b/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(); @@ -251,15 +255,19 @@ std::error_code RawCoverageMappingReader::read(CoverageMappingRecord &Record) { // from the expanded file. // Perform multiple passes to correctly propagate the counters through // all the nested expansion regions. + SmallVector FileIDExpansionRegionMapping; + FileIDExpansionRegionMapping.resize(VirtualFileMapping.size(), nullptr); for (unsigned Pass = 1, S = VirtualFileMapping.size(); Pass < S; ++Pass) { - for (auto &I : MappingRegions) { - if (I.Kind == CounterMappingRegion::ExpansionRegion) { - for (const auto &J : MappingRegions) { - if (J.FileID == I.ExpandedFileID) { - I.Count = J.Count; - break; - } - } + for (auto &R : MappingRegions) { + if (R.Kind != CounterMappingRegion::ExpansionRegion) + continue; + assert(!FileIDExpansionRegionMapping[R.ExpandedFileID]); + FileIDExpansionRegionMapping[R.ExpandedFileID] = &R; + } + for (auto &R : MappingRegions) { + if (FileIDExpansionRegionMapping[R.FileID]) { + FileIDExpansionRegionMapping[R.FileID]->Count = R.Count; + FileIDExpansionRegionMapping[R.FileID] = nullptr; } } } @@ -278,7 +286,7 @@ ObjectFileCoverageMappingReader::ObjectFileCoverageMappingReader( if (!File) error(File.getError()); else - Object.reset(File.get()); + Object = std::move(File.get()); } ObjectFileCoverageMappingReader::ObjectFileCoverageMappingReader( @@ -288,7 +296,7 @@ ObjectFileCoverageMappingReader::ObjectFileCoverageMappingReader( if (!File) error(File.getError()); else - Object.reset(File.get()); + Object = std::move(File.get()); } namespace {