diff options
Diffstat (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp')
-rw-r--r-- | llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp index 87d8bb1..1bf2e8d 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -805,7 +805,6 @@ Error CoverageMapping::loadFunctionRecord( else OrigFuncName = getFuncNameWithoutPrefix(OrigFuncName, Record.Filenames[0]); - bool SingleByteCoverage = ProfileReader.hasSingleByteCoverage(); CounterMappingContext Ctx(Record.Expressions); std::vector<uint64_t> Counts; @@ -871,10 +870,7 @@ Error CoverageMapping::loadFunctionRecord( consumeError(std::move(E)); return Error::success(); } - Function.pushRegion( - Region, (SingleByteCoverage && *ExecutionCount ? 1 : *ExecutionCount), - (SingleByteCoverage && *AltExecutionCount ? 1 : *AltExecutionCount), - SingleByteCoverage); + Function.pushRegion(Region, *ExecutionCount, *AltExecutionCount); // Record ExpansionRegion. if (Region.Kind == CounterMappingRegion::ExpansionRegion) { @@ -936,6 +932,9 @@ Error CoverageMapping::loadFunctionRecord( Error CoverageMapping::loadFromReaders( ArrayRef<std::unique_ptr<CoverageMappingReader>> CoverageReaders, IndexedInstrProfReader &ProfileReader, CoverageMapping &Coverage) { + assert(!Coverage.SingleByteCoverage || + *Coverage.SingleByteCoverage == ProfileReader.hasSingleByteCoverage()); + Coverage.SingleByteCoverage = ProfileReader.hasSingleByteCoverage(); for (const auto &CoverageReader : CoverageReaders) { for (auto RecordOrErr : *CoverageReader) { if (Error E = RecordOrErr.takeError()) @@ -1296,14 +1295,8 @@ class SegmentBuilder { // value for that area. // We add counts of the regions of the same kind as the active region // to handle the both situations. - if (I->Kind == Active->Kind) { - assert(I->HasSingleByteCoverage == Active->HasSingleByteCoverage && - "Regions are generated in different coverage modes"); - if (I->HasSingleByteCoverage) - Active->ExecutionCount = Active->ExecutionCount || I->ExecutionCount; - else - Active->ExecutionCount += I->ExecutionCount; - } + if (I->Kind == Active->Kind) + Active->ExecutionCount += I->ExecutionCount; } return Regions.drop_back(std::distance(++Active, End)); } @@ -1396,7 +1389,8 @@ static bool isExpansion(const CountedRegion &R, unsigned FileID) { } CoverageData CoverageMapping::getCoverageForFile(StringRef Filename) const { - CoverageData FileCoverage(Filename); + assert(SingleByteCoverage); + CoverageData FileCoverage(*SingleByteCoverage, Filename); std::vector<CountedRegion> Regions; // Look up the function records in the given file. Due to hash collisions on @@ -1460,7 +1454,9 @@ CoverageMapping::getCoverageForFunction(const FunctionRecord &Function) const { if (!MainFileID) return CoverageData(); - CoverageData FunctionCoverage(Function.Filenames[*MainFileID]); + assert(SingleByteCoverage); + CoverageData FunctionCoverage(*SingleByteCoverage, + Function.Filenames[*MainFileID]); std::vector<CountedRegion> Regions; for (const auto &CR : Function.CountedRegions) if (CR.FileID == *MainFileID) { @@ -1487,8 +1483,9 @@ CoverageMapping::getCoverageForFunction(const FunctionRecord &Function) const { CoverageData CoverageMapping::getCoverageForExpansion( const ExpansionRecord &Expansion) const { + assert(SingleByteCoverage); CoverageData ExpansionCoverage( - Expansion.Function.Filenames[Expansion.FileID]); + *SingleByteCoverage, Expansion.Function.Filenames[Expansion.FileID]); std::vector<CountedRegion> Regions; for (const auto &CR : Expansion.Function.CountedRegions) if (CR.FileID == Expansion.FileID) { |