@@ -825,157 +825,6 @@ class MCDCDecisionRecorder {
825
825
826
826
} // namespace
827
827
828
- // Error CoverageMapping::loadFunctionRecord(
829
- // const CoverageMappingRecord &Record,
830
- // const std::optional<std::reference_wrapper<IndexedInstrProfReader>>
831
- // &ProfileReader, StringRef Arch) {
832
- // StringRef OrigFuncName = Record.FunctionName;
833
- // if (OrigFuncName.empty())
834
- // return make_error<CoverageMapError>(coveragemap_error::malformed,
835
- // "record function name is empty");
836
-
837
- // if (Record.Filenames.empty())
838
- // OrigFuncName = getFuncNameWithoutPrefix(OrigFuncName);
839
- // else
840
- // OrigFuncName = getFuncNameWithoutPrefix(OrigFuncName, Record.Filenames[0]);
841
-
842
- // CounterMappingContext Ctx(Record.Expressions);
843
-
844
- // uint64_t FuncArchHash = Record.FunctionHash;
845
- // if(!Arch.empty()){
846
- // std::string HashStr = std::to_string(Record.FunctionHash) + ":" + Arch.str();
847
- // llvm::StringRef HashRef(HashStr);
848
- // FuncArchHash = IndexedInstrProf::ComputeHash(HashRef);
849
- // }
850
-
851
- // std::vector<uint64_t> Counts;
852
- // if (ProfileReader) {
853
- // if (Error E = ProfileReader.value().get().getFunctionCounts(
854
- // Record.FunctionName, FuncArchHash, Counts)) {
855
- // instrprof_error IPE = std::get<0>(InstrProfError::take(std::move(E)));
856
- // if (IPE == instrprof_error::hash_mismatch) {
857
- // FuncHashMismatches.emplace_back(std::string(Record.FunctionName),
858
- // FuncArchHash);
859
- // return Error::success();
860
- // }
861
- // if (IPE != instrprof_error::unknown_function)
862
- // return make_error<InstrProfError>(IPE);
863
- // Counts.assign(getMaxCounterID(Ctx, Record) + 1, 0);
864
- // }
865
- // } else {
866
- // Counts.assign(getMaxCounterID(Ctx, Record) + 1, 0);
867
- // }
868
- // Ctx.setCounts(Counts);
869
-
870
- // bool IsVersion11 =
871
- // ProfileReader && ProfileReader.value().get().getVersion() <
872
- // IndexedInstrProf::ProfVersion::Version12;
873
-
874
- // BitVector Bitmap;
875
- // if (ProfileReader) {
876
- // if (Error E = ProfileReader.value().get().getFunctionBitmap(
877
- // Record.FunctionName, FuncArchHash, Bitmap)) {
878
- // instrprof_error IPE = std::get<0>(InstrProfError::take(std::move(E)));
879
- // if (IPE == instrprof_error::hash_mismatch) {
880
- // FuncHashMismatches.emplace_back(std::string(Record.FunctionName),
881
- // FuncArchHash);
882
- // return Error::success();
883
- // }
884
- // if (IPE != instrprof_error::unknown_function)
885
- // return make_error<InstrProfError>(IPE);
886
- // Bitmap = BitVector(getMaxBitmapSize(Record, IsVersion11));
887
- // }
888
- // } else {
889
- // Bitmap = BitVector(getMaxBitmapSize(Record, false));
890
- // }
891
- // Ctx.setBitmap(std::move(Bitmap));
892
-
893
- // assert(!Record.MappingRegions.empty() && "Function has no regions");
894
-
895
- // // This coverage record is a zero region for a function that's unused in
896
- // // some TU, but used in a different TU. Ignore it. The coverage maps from the
897
- // // the other TU will either be loaded (providing full region counts) or they
898
- // // won't (in which case we don't unintuitively report functions as uncovered
899
- // // when they have non-zero counts in the profile).
900
- // if (Record.MappingRegions.size() == 1 &&
901
- // Record.MappingRegions[0].Count.isZero() && Counts[0] > 0)
902
- // return Error::success();
903
-
904
- // MCDCDecisionRecorder MCDCDecisions;
905
- // FunctionRecord Function(OrigFuncName, Record.Filenames);
906
- // for (const auto &Region : Record.MappingRegions) {
907
- // // MCDCDecisionRegion should be handled first since it overlaps with
908
- // // others inside.
909
- // if (Region.Kind == CounterMappingRegion::MCDCDecisionRegion) {
910
- // MCDCDecisions.registerDecision(Region);
911
- // continue;
912
- // }
913
- // Expected<int64_t> ExecutionCount = Ctx.evaluate(Region.Count);
914
- // if (auto E = ExecutionCount.takeError()) {
915
- // consumeError(std::move(E));
916
- // return Error::success();
917
- // }
918
- // Expected<int64_t> AltExecutionCount = Ctx.evaluate(Region.FalseCount);
919
- // if (auto E = AltExecutionCount.takeError()) {
920
- // consumeError(std::move(E));
921
- // return Error::success();
922
- // }
923
- // Function.pushRegion(Region, *ExecutionCount, *AltExecutionCount);
924
-
925
- // // Record ExpansionRegion.
926
- // if (Region.Kind == CounterMappingRegion::ExpansionRegion) {
927
- // MCDCDecisions.recordExpansion(Region);
928
- // continue;
929
- // }
930
-
931
- // // Do nothing unless MCDCBranchRegion.
932
- // if (Region.Kind != CounterMappingRegion::MCDCBranchRegion)
933
- // continue;
934
-
935
- // auto Result = MCDCDecisions.processBranch(Region);
936
- // if (!Result) // Any Decision doesn't complete.
937
- // continue;
938
-
939
- // auto MCDCDecision = Result->first;
940
- // auto &MCDCBranches = Result->second;
941
-
942
- // // Since the bitmap identifies the executed test vectors for an MC/DC
943
- // // DecisionRegion, all of the information is now available to process.
944
- // // This is where the bulk of the MC/DC progressing takes place.
945
- // Expected<MCDCRecord> Record =
946
- // Ctx.evaluateMCDCRegion(*MCDCDecision, MCDCBranches, IsVersion11);
947
- // if (auto E = Record.takeError()) {
948
- // consumeError(std::move(E));
949
- // return Error::success();
950
- // }
951
-
952
- // // Save the MC/DC Record so that it can be visualized later.
953
- // Function.pushMCDCRecord(std::move(*Record));
954
- // }
955
-
956
- // // Don't create records for (filenames, function) pairs we've already seen.
957
- // auto FilenamesHash = hash_combine_range(Record.Filenames);
958
- // if (!RecordProvenance[FilenamesHash].insert(hash_value(OrigFuncName)).second)
959
- // return Error::success();
960
-
961
- // Functions.push_back(std::move(Function));
962
-
963
- // // Performance optimization: keep track of the indices of the function records
964
- // // which correspond to each filename. This can be used to substantially speed
965
- // // up queries for coverage info in a file.
966
- // unsigned RecordIndex = Functions.size() - 1;
967
- // for (StringRef Filename : Record.Filenames) {
968
- // auto &RecordIndices = FilenameHash2RecordIndices[hash_value(Filename)];
969
- // // Note that there may be duplicates in the filename set for a function
970
- // // record, because of e.g. macro expansions in the function in which both
971
- // // the macro and the function are defined in the same file.
972
- // if (RecordIndices.empty() || RecordIndices.back() != RecordIndex)
973
- // RecordIndices.push_back(RecordIndex);
974
- // }
975
-
976
- // return Error::success();
977
- // }
978
-
979
828
Error CoverageMapping::loadFunctionRecord (
980
829
const CoverageMappingRecord &Record,
981
830
const std::optional<std::reference_wrapper<IndexedInstrProfReader>>
@@ -1200,7 +1049,6 @@ Error CoverageMapping::loadFromReaders(
1200
1049
&ProfileReader,
1201
1050
CoverageMapping &Coverage, StringRef Arch, StringRef ObjectFilename, bool ShowArchExecutables, bool MergeBinaryCoverage) {
1202
1051
1203
- // Coverage.setArchitecture(Arch);
1204
1052
assert (!Coverage.SingleByteCoverage || !ProfileReader ||
1205
1053
*Coverage.SingleByteCoverage ==
1206
1054
ProfileReader.value ().get ().hasSingleByteCoverage ());
@@ -1308,9 +1156,6 @@ Expected<std::unique_ptr<CoverageMapping>> CoverageMapping::load(
1308
1156
return Arches[Idx];
1309
1157
};
1310
1158
1311
- // I beleive there is an error in this area of code, it's iterating through all arch's of the object files
1312
- // but its only filling *Coverage with last architecture it gets to
1313
-
1314
1159
SmallVector<object::BuildID> FoundBinaryIDs;
1315
1160
for (const auto &File : llvm::enumerate (ObjectFilenames)) {
1316
1161
if (Error E = loadFromFile (File.value (), GetArch (File.index ()),
@@ -1320,9 +1165,6 @@ Expected<std::unique_ptr<CoverageMapping>> CoverageMapping::load(
1320
1165
return std::move (E);
1321
1166
}
1322
1167
1323
- // I beleive there is an error in this area of code, it's iterating through all arch's of the object files
1324
- // but its only filling *Coverage with last architecture it gets to
1325
-
1326
1168
if (BIDFetcher) {
1327
1169
std::vector<object::BuildID> ProfileBinaryIDs;
1328
1170
if (ProfileReader)
@@ -1561,7 +1403,6 @@ class SegmentBuilder {
1561
1403
}
1562
1404
1563
1405
// / Combine counts of regions which cover the same area.
1564
- // [(3:12, 10:1), (4:1, 6:7), (6:7, 8:1)]
1565
1406
static ArrayRef<CountedRegion>
1566
1407
combineRegions (MutableArrayRef<CountedRegion> Regions) {
1567
1408
if (Regions.empty ())
@@ -1576,8 +1417,6 @@ class SegmentBuilder {
1576
1417
++Active;
1577
1418
if (Active != I){
1578
1419
*Active = *I;
1579
- // Active->ExecutionCount = 1;
1580
- // Active->Kind = CounterMappingRegion::CodeRegion;
1581
1420
}
1582
1421
continue ;
1583
1422
}
@@ -1608,14 +1447,16 @@ class SegmentBuilder {
1608
1447
1609
1448
sortNestedRegions (Regions);
1610
1449
1450
+
1451
+ // check to see if a skipped region from executable A is within a CodeRegion from executable B,
1452
+ // promote to CodeRegion if skipped region does not show up on any other executable.
1611
1453
for (auto *I = Regions.begin (); I != Regions.end (); ++I){
1612
1454
bool FoundMatchInOtherBinary = false ;
1613
1455
for (auto *J = I + 1 ; J != Regions.end (); ++J){
1614
1456
if (I->ObjectFilename != J->ObjectFilename &&
1615
1457
J->Kind == CounterMappingRegion::SkippedRegion
1616
1458
&& I->Kind != CounterMappingRegion::SkippedRegion &&
1617
1459
J->startLoc () >= I->startLoc () && J->endLoc () <= I->endLoc ()){
1618
- // llvm::errs() << "(" << to_string(J->startLoc().first) << ", " << to_string(J->endLoc().first) << ")" << "\n";
1619
1460
for (auto *K = J + 1 ; K != Regions.end (); ++K){
1620
1461
if (K->ObjectFilename == I->ObjectFilename &&
1621
1462
J->startLoc () == K->startLoc () && J->endLoc () == K->endLoc ()){
@@ -1686,12 +1527,7 @@ static SmallBitVector gatherFileIDs(StringRef SourceFile,
1686
1527
static std::optional<unsigned >
1687
1528
findMainViewFileID (const FunctionRecord &Function) {
1688
1529
SmallBitVector IsNotExpandedFile (Function.Filenames .size (), true );
1689
- uint64_t counter = 0 ;
1690
1530
for (const auto &CR : Function.CountedRegions ){
1691
- // counter++;
1692
- // if(counter == 245){
1693
- // llvm::errs() << counter << "\n";
1694
- // }
1695
1531
if (CR.Kind == CounterMappingRegion::ExpansionRegion)
1696
1532
IsNotExpandedFile[CR.ExpandedFileID ] = false ;
1697
1533
}
@@ -1726,14 +1562,6 @@ CoverageData CoverageMapping::getCoverageForFile(StringRef Filename, bool ShowAr
1726
1562
// DenseSet<CountedRegion> DeDuplicationSet;
1727
1563
ArrayRef<unsigned > RecordIndices =
1728
1564
getImpreciseRecordIndicesForFilename (Filename);
1729
- // for (unsigned RecordIndex : RecordIndices) {
1730
- // const FunctionRecord &Function = AllFunctionRegions[RecordIndex];
1731
- // for(const auto &I : Function.CountedRegions){
1732
- // llvm::errs() << "(" << to_string(I.startLoc().first) << ", " << to_string(I.endLoc().first) << ")" << "\n";
1733
- // }
1734
- // }
1735
- // ArrayRef<unsigned> RecordIndices =
1736
- // getImpreciseRecordIndicesForFilename(Filename);
1737
1565
for (unsigned RecordIndex : RecordIndices) {
1738
1566
const FunctionRecord &Function = !MergeBinaryCoverage ? Functions[RecordIndex] : AllFunctionRegions[RecordIndex];
1739
1567
auto MainFileID = findMainViewFileID (Filename, Function);
0 commit comments