@@ -805,7 +805,6 @@ Error CoverageMapping::loadFunctionRecord(
805
805
else
806
806
OrigFuncName = getFuncNameWithoutPrefix (OrigFuncName, Record.Filenames [0 ]);
807
807
808
- bool SingleByteCoverage = ProfileReader.hasSingleByteCoverage ();
809
808
CounterMappingContext Ctx (Record.Expressions );
810
809
811
810
std::vector<uint64_t > Counts;
@@ -871,10 +870,7 @@ Error CoverageMapping::loadFunctionRecord(
871
870
consumeError (std::move (E));
872
871
return Error::success ();
873
872
}
874
- Function.pushRegion (
875
- Region, (SingleByteCoverage && *ExecutionCount ? 1 : *ExecutionCount),
876
- (SingleByteCoverage && *AltExecutionCount ? 1 : *AltExecutionCount),
877
- SingleByteCoverage);
873
+ Function.pushRegion (Region, *ExecutionCount, *AltExecutionCount);
878
874
879
875
// Record ExpansionRegion.
880
876
if (Region.Kind == CounterMappingRegion::ExpansionRegion) {
@@ -936,6 +932,9 @@ Error CoverageMapping::loadFunctionRecord(
936
932
Error CoverageMapping::loadFromReaders (
937
933
ArrayRef<std::unique_ptr<CoverageMappingReader>> CoverageReaders,
938
934
IndexedInstrProfReader &ProfileReader, CoverageMapping &Coverage) {
935
+ assert (!Coverage.SingleByteCoverage ||
936
+ *Coverage.SingleByteCoverage == ProfileReader.hasSingleByteCoverage ());
937
+ Coverage.SingleByteCoverage = ProfileReader.hasSingleByteCoverage ();
939
938
for (const auto &CoverageReader : CoverageReaders) {
940
939
for (auto RecordOrErr : *CoverageReader) {
941
940
if (Error E = RecordOrErr.takeError ())
@@ -1296,14 +1295,8 @@ class SegmentBuilder {
1296
1295
// value for that area.
1297
1296
// We add counts of the regions of the same kind as the active region
1298
1297
// to handle the both situations.
1299
- if (I->Kind == Active->Kind ) {
1300
- assert (I->HasSingleByteCoverage == Active->HasSingleByteCoverage &&
1301
- " Regions are generated in different coverage modes" );
1302
- if (I->HasSingleByteCoverage )
1303
- Active->ExecutionCount = Active->ExecutionCount || I->ExecutionCount ;
1304
- else
1305
- Active->ExecutionCount += I->ExecutionCount ;
1306
- }
1298
+ if (I->Kind == Active->Kind )
1299
+ Active->ExecutionCount += I->ExecutionCount ;
1307
1300
}
1308
1301
return Regions.drop_back (std::distance (++Active, End));
1309
1302
}
@@ -1396,7 +1389,8 @@ static bool isExpansion(const CountedRegion &R, unsigned FileID) {
1396
1389
}
1397
1390
1398
1391
CoverageData CoverageMapping::getCoverageForFile (StringRef Filename) const {
1399
- CoverageData FileCoverage (Filename);
1392
+ assert (SingleByteCoverage);
1393
+ CoverageData FileCoverage (*SingleByteCoverage, Filename);
1400
1394
std::vector<CountedRegion> Regions;
1401
1395
1402
1396
// Look up the function records in the given file. Due to hash collisions on
@@ -1460,7 +1454,9 @@ CoverageMapping::getCoverageForFunction(const FunctionRecord &Function) const {
1460
1454
if (!MainFileID)
1461
1455
return CoverageData ();
1462
1456
1463
- CoverageData FunctionCoverage (Function.Filenames [*MainFileID]);
1457
+ assert (SingleByteCoverage);
1458
+ CoverageData FunctionCoverage (*SingleByteCoverage,
1459
+ Function.Filenames [*MainFileID]);
1464
1460
std::vector<CountedRegion> Regions;
1465
1461
for (const auto &CR : Function.CountedRegions )
1466
1462
if (CR.FileID == *MainFileID) {
@@ -1487,8 +1483,9 @@ CoverageMapping::getCoverageForFunction(const FunctionRecord &Function) const {
1487
1483
1488
1484
CoverageData CoverageMapping::getCoverageForExpansion (
1489
1485
const ExpansionRecord &Expansion) const {
1486
+ assert (SingleByteCoverage);
1490
1487
CoverageData ExpansionCoverage (
1491
- Expansion.Function .Filenames [Expansion.FileID ]);
1488
+ *SingleByteCoverage, Expansion.Function .Filenames [Expansion.FileID ]);
1492
1489
std::vector<CountedRegion> Regions;
1493
1490
for (const auto &CR : Expansion.Function .CountedRegions )
1494
1491
if (CR.FileID == Expansion.FileID ) {
0 commit comments