LLVM: include/llvm/ProfileData/Coverage/CoverageMapping.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H
15#define LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H
16
34#include
35#include
36#include
37#include
38#include
39#include
40#include
41#include
42#include
43#include <system_error>
44#include
45#include
46
47namespace llvm {
48
50
53}
54
55namespace vfs {
57}
58
60
63
74
76
80
82public:
84 : Err(Err), Msg(ErrStr.str()) {
86 }
88 std::string message() const override;
92 std::error_code convertToErrorCode() const override {
97 const std::string &getMessage() const { return Msg; }
98
100
101private:
103 std::string Msg;
104};
105
106
107
108struct Counter {
116
117private:
119 unsigned ID = 0;
120
122
123public:
125
127
129
131
133
135
143
145 return std::tie(LHS.Kind, LHS.ID) < std::tie(RHS.Kind, RHS.ID);
146 }
147
148
150
151
155
156
157
161};
162
163
164
167 ExprKind Kind;
169
172};
173
174
175
177
178 std::vector Expressions;
179
180
182
183
184
185
186
190
191 struct Term {
192 unsigned CounterID;
193 int Factor;
194
195 Term(unsigned CounterID, int Factor)
196 : CounterID(CounterID), Factor(Factor) {}
197 };
198
199
200
201
202
203
205
206
207
209
210public:
212
213
215
216
217
219
220
221
222 using SubstMap = std::map<Counter, Counter>;
223
224
225
227};
228
230
231
234
236
237
238
239
241
242
243
245
246
247
249
250
251
252
254
261 };
262
265
266
269
279
283
285
289
305 Kind(Kind) {}
306
314
321
329
336
343
356
364
368
370};
371
372
389
390
392
393
394
395
396
397
399
400
401
402
403
404
406 BitVector Values;
408
409 public:
410
412
413
418
419
420 auto getIndex() const { return Values.getData()[0]; }
421
422
423
428
429
432 Values.push_back(Val == MCDC_True);
433 assert(Values.size() == Visited.size());
434 }
435
436
437
438
439
440
441
443 const auto &A = *this;
445 AB ^= B.Values;
446 AB &= A.Visited;
447 AB &= B.Visited;
448 return AB;
449 }
450 };
451
454 using TVRowPair = std::pair<unsigned, unsigned>;
458
459private:
462 std::optional IndependencePairs;
466
467public:
474
475
476
478
481 return Region.getDecisionParams().NumConditions;
482 }
485 return Folded[false][Condition] || Folded[true][Condition];
486 }
487
488
489
490
491
492
493
495 return TV[TestVectorIndex].first[PosToID[Condition]];
496 }
497
498
499
501 const unsigned TrueDecisions =
503
504 return {TrueDecisions, TV.size() - TrueDecisions};
505 }
506
507
508
510 return TV[TestVectorIndex].second;
511 }
512
513
514
515
516
517
519 assert(IndependencePairs);
520 auto It = PosToID.find(Condition);
521 assert(It != PosToID.end() && "Condition ID without an Ordinal mapping");
522 return IndependencePairs->contains(It->second);
523 }
524
525
526
527
528
529
532 assert(IndependencePairs);
533 return (*IndependencePairs)[PosToID[Condition]];
534 }
535
537 unsigned Folded = 0;
538 unsigned Covered = 0;
541 Folded++;
543 Covered++;
544 }
545
548 return 0.0;
549 return (static_cast<double>(Covered) / static_cast<double>(Total)) * 100.0;
550 }
551
553 std::ostringstream OS;
554 const auto &[Line, Col] = CondLoc[Condition];
555 OS << "Condition C" << Condition + 1 << " --> (" << Line << ":" << Col
556 << ")\n";
557 return OS.str();
558 }
559
561 std::ostringstream OS;
563 OS << "None.\n";
564 return OS.str();
565 }
567 for (unsigned I = 0; I < NumConditions; I++) {
568 OS << "C" << I + 1;
569 if (I != NumConditions - 1)
570 OS << ", ";
571 }
572 OS << " Result\n";
573 return OS.str();
574 }
575
578 "TestVector index out of bounds!");
579 std::ostringstream OS;
581
582 OS << " " << TestVectorIndex + 1 << " { ";
583 for (unsigned Condition = 0; Condition < NumConditions; Condition++) {
585 OS << "C";
586 else {
587 switch (getTVCondition(TestVectorIndex, Condition)) {
589 OS << "-";
590 break;
592 OS << "T";
593 break;
595 OS << "F";
596 break;
597 }
598 }
599 if (Condition != NumConditions - 1)
600 OS << ", ";
601 }
602
603
604 OS << " = ";
606 OS << "T";
607 else
608 OS << "F";
609 OS << " }\n";
610
611 return OS.str();
612 }
613
616 "Condition index is out of bounds!");
617 std::ostringstream OS;
618
619 OS << " C" << Condition + 1 << "-Pair: ";
621 OS << "constant folded\n";
624 OS << "covered: (" << rows.first << ",";
625 OS << rows.second << ")\n";
626 } else
627 OS << "not covered\n";
628
629 return OS.str();
630 }
631};
632
634
635
636
637
638
639
640
641
642
643
644
645
646
647
649public:
655
656#ifndef NDEBUG
657
658
660#endif
661
662
664
665
666
668
669
672
673public:
674
675
676
677
680};
681}
682
683
684
689
690public:
693 : Expressions(Expressions), CounterValues(CounterValues) {}
694
697
700
701
702
704
705
706
710 bool IsVersion11);
711
713};
714
715
717
719
720
721
722
723
724
726
728
730
732
734
737
740
744
747 if (Region.isBranch()) {
749
750
753 return;
754 }
758 }
759};
760
761
762
763
764
767 std::forward_iterator_tag, FunctionRecord> {
773
774
775 LLVM_ABI void skipOtherFiles();
776
777public:
781 : Records(Records_), RecordIndices(RecordIndices_),
782 CurrentIndex(RecordIndices.begin()),
783
784
785 Current(CurrentIndex == RecordIndices.end() ? Records.begin()
786 : &Records[*CurrentIndex]),
787 Filename(Filename) {
788 assert(Filename.empty() == RecordIndices_.empty() &&
789 "If `Filename` is specified, `RecordIndices` must also be provided");
790 skipOtherFiles();
791 }
792
794
796 return Current == RHS.Current && Filename == RHS.Filename;
797 }
798
800
802 advanceOne();
803 skipOtherFiles();
804 return *this;
805 }
806
807private:
808 void advanceOne() {
809 if (RecordIndices.empty()) {
810
811 assert(Current != Records.end() && "incremented past end");
812 ++Current;
813 } else {
814
815
816 assert(CurrentIndex != RecordIndices.end() && "incremented past end");
817 ++CurrentIndex;
818 if (CurrentIndex == RecordIndices.end()) {
819 Current = Records.end();
820 } else {
821 Current = &Records[*CurrentIndex];
822 }
823 }
824 }
825};
826
827
828
829
830
831
844
845
846
847
848
850
852
854
856
858
860
862
866
869 bool IsBranchRegion = false)
872
874 return std::tie(L.Line, L.Col, L.Count, L.HasCount, L.IsRegionEntry,
875 L.IsGapRegion) == std::tie(R.Line, R.Col, R.Count,
876 R.HasCount, R.IsRegionEntry,
877 R.IsGapRegion);
878 }
879};
880
881
882
883
884
885
886class InstantiationGroup {
888
889 unsigned Line;
890 unsigned Col;
891 std::vector<const FunctionRecord *> Instantiations;
892
893 InstantiationGroup(unsigned Line, unsigned Col,
894 std::vector<const FunctionRecord *> Instantiations)
895 : Line(Line), Col(Col), Instantiations(std::move(Instantiations)) {}
896
897public:
900
901
902 size_t size() const { return Instantiations.size(); }
903
904
905 unsigned getLine() const { return Line; }
906
907
909
910
912 for (unsigned I = 1, E = Instantiations.size(); I < E; ++I)
913 if (Instantiations[I]->Name != Instantiations[0]->Name)
914 return false;
915 return true;
916 }
917
918
920 assert(hasName() && "Instantiations don't have a shared name");
921 return Instantiations[0]->Name;
922 }
923
924
928 Count += F->ExecutionCount;
930 }
931
932
934 return Instantiations;
935 }
936};
937
938
939
940
941
942
945
946 std::string Filename;
947 std::vector Segments;
948 std::vector Expansions;
949 std::vector BranchRegions;
950 std::vector MCDCRecords;
951
952 bool SingleByteCoverage = false;
953
954public:
956
958 : Filename(Filename), SingleByteCoverage(Single) {}
959
960
962
964
965
966
967 std::vector::const_iterator begin() const {
968 return Segments.begin();
969 }
970
971 std::vector::const_iterator end() const {
972 return Segments.end();
973 }
974
975 bool empty() const { return Segments.empty(); }
976
977
979
980
982
983
985};
986
987
988
989
990
991class CoverageMapping {
993 std::vector Functions;
995 std::vector<std::pair<std::string, uint64_t>> FuncHashMismatches;
996
997 std::optional SingleByteCoverage;
998
999 CoverageMapping() = default;
1000
1001
1002 static Error loadFromReaders(
1003 ArrayRef<std::unique_ptr> CoverageReaders,
1004 std::optional<std::reference_wrapper>
1005 &ProfileReader,
1006 CoverageMapping &Coverage);
1011 std::optional<std::reference_wrapper>
1012 &ProfileReader,
1019 const std::optional<std::reference_wrapper>
1020 &ProfileReader);
1021
1023
1024
1025
1027 getImpreciseRecordIndicesForFilename(StringRef Filename) const;
1028
1029public:
1035 load(ArrayRef<std::unique_ptr> CoverageReaders,
1036 std::optional<std::reference_wrapper>
1037 &ProfileReader);
1047 bool CheckBinaryIDs = false);
1048
1049
1050
1051
1052
1054
1055
1056
1057
1058
1060 return FuncHashMismatches;
1061 }
1062
1063
1064
1066
1067
1068
1069
1070
1071
1073
1074
1077
1078
1081
1082
1087
1088
1093 getImpreciseRecordIndicesForFilename(Filename)),
1095 }
1096
1097
1098
1099
1100
1101 LLVM_ABI std::vector
1103};
1104
1105
1106class LineCoverageStats {
1108 bool HasMultipleRegions;
1109 bool Mapped;
1110 unsigned Line;
1113
1115 LineCoverageStats() = default;
1116
1117public:
1120 unsigned Line);
1121
1123
1125
1127
1128 unsigned getLine() const { return Line; }
1129
1131 return LineSegments;
1132 }
1133
1135};
1136
1137
1138
1141 std::forward_iterator_tag,
1142 const LineCoverageStats> {
1143public:
1146
1148 : CD(CD), WrappedSegment(nullptr), Next(CD.begin()), Ended(false),
1149 Line(Line) {
1151 }
1152
1154 return &CD == &R.CD && Next == R.Next && Ended == R.Ended;
1155 }
1156
1158
1160
1162 auto EndIt = *this;
1163 EndIt.Next = CD.end();
1164 EndIt.Ended = true;
1165 return EndIt;
1166 }
1167
1168private:
1171 std::vector::const_iterator Next;
1172 bool Ended;
1173 unsigned Line;
1176};
1177
1178
1182 auto End = Begin.getEnd();
1184}
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1214
1215
1216template <class FuncRecordTy, llvm::endianness Endian>
1220
1221
1222template <class FuncRecordTy, llvm::endianness Endian>
1226
1227
1228template <class FuncRecordTy, llvm::endianness Endian>
1232
1233
1234
1235template <class FuncRecordTy, llvm::endianness Endian>
1242
1243
1244
1245
1246template <class FuncRecordTy, llvm::endianness Endian>
1248 const char *MappingBuf) {
1250}
1251
1252
1253
1254template <class FuncRecordTy, llvm::endianness Endian>
1255std::pair<const char *, const FuncRecordTy *>
1259
1260}
1261
1263template
1266
1267#define COVMAP_V1
1268#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
1270#undef COVMAP_V1
1271 CovMapFunctionRecordV1() = delete;
1272
1275 }
1276
1277 template <llvm::endianness Endian> uint64_t getDataSize() const {
1279 }
1280
1281
1282 template <llvm::endianness Endian> IntPtrT getFuncNameRef() const {
1284 }
1285
1286
1287 template <llvm::endianness Endian>
1288 Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const {
1291 FuncName = ProfileNames.getFuncName(NameRef, NameS);
1292 if (NameS && FuncName.empty())
1294 "function name is empty");
1296 }
1297
1298 template <llvm::endianness Endian>
1299 std::pair<const char *, const ThisT *>
1300 advanceByOne(const char *MappingBuf) const {
1302 }
1303
1304 template <llvm::endianness Endian> uint64_t getFilenamesRef() const {
1305 llvm_unreachable("V1 function format does not contain a filenames ref");
1306 }
1307
1308 template <llvm::endianness Endian>
1311 MappingBuf);
1312 }
1313};
1314
1317
1318#define COVMAP_V2
1319#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
1321#undef COVMAP_V2
1322 CovMapFunctionRecordV2() = delete;
1323
1326 }
1327
1328 template <llvm::endianness Endian> uint64_t getDataSize() const {
1330 }
1331
1332 template <llvm::endianness Endian> uint64_t getFuncNameRef() const {
1334 }
1335
1336 template <llvm::endianness Endian>
1337 Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const {
1339 FuncName);
1340 }
1341
1342 template <llvm::endianness Endian>
1343 std::pair<const char *, const ThisT *>
1344 advanceByOne(const char *MappingBuf) const {
1346 }
1347
1348 template <llvm::endianness Endian> uint64_t getFilenamesRef() const {
1349 llvm_unreachable("V2 function format does not contain a filenames ref");
1350 }
1351
1352 template <llvm::endianness Endian>
1355 MappingBuf);
1356 }
1357};
1358
1361
1362#define COVMAP_V3
1363#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
1365#undef COVMAP_V3
1366 CovMapFunctionRecordV3() = delete;
1367
1370 }
1371
1372 template <llvm::endianness Endian> uint64_t getDataSize() const {
1374 }
1375
1376 template <llvm::endianness Endian> uint64_t getFuncNameRef() const {
1378 }
1379
1380 template <llvm::endianness Endian>
1381 Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const {
1383 FuncName);
1384 }
1385
1386
1387 template <llvm::endianness Endian> uint64_t getFilenamesRef() const {
1389 }
1390
1391
1392
1393 template <llvm::endianness Endian>
1396 }
1397
1398
1399
1400 template <llvm::endianness Endian>
1401 std::pair<const char *, const CovMapFunctionRecordV3 *>
1404 const char *Next = ((const char *)this) + sizeof(CovMapFunctionRecordV3) -
1406
1407
1409 return {nullptr, reinterpret_cast<const CovMapFunctionRecordV3 *>(Next)};
1410 }
1411};
1412
1413
1414
1416#define COVMAP_HEADER(Type, LLVMType, Name, Init) Type Name;
1418 template <llvm::endianness Endian> uint32_t getNRecords() const {
1420 }
1421
1422 template <llvm::endianness Endian> uint32_t getFilenamesSize() const {
1424 }
1425
1426 template <llvm::endianness Endian> uint32_t getCoverageSize() const {
1428 }
1429
1430 template <llvm::endianness Endian> uint32_t getVersion() const {
1432 }
1433};
1434
1436
1439
1440
1441
1443
1444
1446
1448
1450
1451
1453
1455
1457};
1458
1459
1461
1463
1464
1466
1467
1469
1471};
1472
1477
1482
1487
1492
1493}
1494
1495
1499
1500 return CounterExpression(CounterExpression::ExprKind::Subtract,
1501 Counter::getCounter(~0U),
1502 Counter::getCounter(~0U));
1503 }
1504
1507
1508 return CounterExpression(CounterExpression::ExprKind::Add,
1509 Counter::getCounter(~0U),
1510 Counter::getCounter(~0U));
1511 }
1512
1514 return static_cast<unsigned>(
1515 hash_combine(V.Kind, V.LHS.getKind(), V.LHS.getCounterID(),
1516 V.RHS.getKind(), V.RHS.getCounterID()));
1517 }
1518
1523};
1524
1525}
1526
1527#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Mark last scratch load
This file implements the BitVector class.
This file declares a library for handling Build IDs and using them to find debug info.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_PACKED_START
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
#define INSTR_PROF_COVMAP_VERSION
block placement Basic Block Placement Stats
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
empty - Check if the array is empty.
Base class for user error types.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Reader for the indexed binary instrprof format.
A symbol table used for function [IR]PGO name look-up with keys (such as pointers,...
StringRef getFuncOrVarName(uint64_t ValMD5Hash) const
Return name of functions or global variables from the name's md5 hash value.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
A Counter expression builder is used to construct the counter expressions.
Definition CoverageMapping.h:176
ArrayRef< CounterExpression > getExpressions() const
Definition CoverageMapping.h:211
LLVM_ABI Counter subtract(Counter LHS, Counter RHS, bool Simplify=true)
Return a counter that represents the expression that subtracts RHS from LHS.
LLVM_ABI Counter add(Counter LHS, Counter RHS, bool Simplify=true)
Return a counter that represents the expression that adds LHS and RHS.
LLVM_ABI Counter subst(Counter C, const SubstMap &Map)
std::map< Counter, Counter > SubstMap
K to V map.
Definition CoverageMapping.h:222
LLVM_ABI Expected< MCDCRecord > evaluateMCDCRegion(const CounterMappingRegion &Region, ArrayRef< const CounterMappingRegion * > Branches, bool IsVersion11)
Return an MCDC record that indicates executed test vectors and condition pairs.
void setCounts(ArrayRef< uint64_t > Counts)
Definition CoverageMapping.h:695
void dump(const Counter &C) const
Definition CoverageMapping.h:699
LLVM_ABI Expected< int64_t > evaluate(const Counter &C) const
Return the number of times that a region of code associated with this counter was executed.
void setBitmap(BitVector &&Bitmap_)
Definition CoverageMapping.h:696
LLVM_ABI unsigned getMaxCounterID(const Counter &C) const
CounterMappingContext(ArrayRef< CounterExpression > Expressions, ArrayRef< uint64_t > CounterValues={})
Definition CoverageMapping.h:691
LLVM_ABI void dump(const Counter &C, raw_ostream &OS) const
Coverage information to be processed or displayed.
Definition CoverageMapping.h:943
bool getSingleByteCoverage() const
Definition CoverageMapping.h:963
ArrayRef< ExpansionRecord > getExpansions() const
Expansions that can be further processed.
Definition CoverageMapping.h:978
ArrayRef< CountedRegion > getBranches() const
Branches that can be further processed.
Definition CoverageMapping.h:981
std::vector< CoverageSegment >::const_iterator begin() const
Get an iterator over the coverage segments for this object.
Definition CoverageMapping.h:967
std::vector< CoverageSegment >::const_iterator end() const
Definition CoverageMapping.h:971
friend class CoverageMapping
Definition CoverageMapping.h:944
bool empty() const
Definition CoverageMapping.h:975
StringRef getFilename() const
Get the name of the file this data covers.
Definition CoverageMapping.h:961
ArrayRef< MCDCRecord > getMCDCRecords() const
MCDC Records that can be further processed.
Definition CoverageMapping.h:984
CoverageData(bool Single, StringRef Filename)
Definition CoverageMapping.h:957
std::string message() const override
Return the error message as a string.
static char ID
Definition CoverageMapping.h:99
CoverageMapError(coveragemap_error Err, const Twine &ErrStr=Twine())
Definition CoverageMapping.h:83
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition CoverageMapping.h:90
const std::string & getMessage() const
Definition CoverageMapping.h:97
The mapping of profile information to coverage data.
Definition CoverageMapping.h:991
unsigned getMismatchedCount() const
The number of functions that couldn't have their profiles mapped.
Definition CoverageMapping.h:1053
LLVM_ABI std::vector< StringRef > getUniqueSourceFiles() const
Returns a lexicographically sorted, unique list of files that are covered.
LLVM_ABI CoverageData getCoverageForExpansion(const ExpansionRecord &Expansion) const
Get the coverage for an expansion within a coverage set.
ArrayRef< std::pair< std::string, uint64_t > > getHashMismatches() const
A hash mismatch occurs when a profile record for a symbol does not have the same hash as a coverage m...
Definition CoverageMapping.h:1059
iterator_range< FunctionRecordIterator > getCoveredFunctions(StringRef Filename) const
Gets all of the functions in a particular file.
Definition CoverageMapping.h:1090
iterator_range< FunctionRecordIterator > getCoveredFunctions() const
Gets all of the functions covered by this profile.
Definition CoverageMapping.h:1083
LLVM_ABI CoverageData getCoverageForFunction(const FunctionRecord &Function) const
Get the coverage for a particular function.
CoverageMapping(const CoverageMapping &)=delete
LLVM_ABI std::vector< InstantiationGroup > getInstantiationGroups(StringRef Filename) const
Get the list of function instantiation groups in a particular file.
LLVM_ABI CoverageData getCoverageForFile(StringRef Filename) const
Get the coverage for a particular file.
CoverageMapping & operator=(const CoverageMapping &)=delete
Iterator over Functions, optionally filtered to a single file.
Definition CoverageMapping.h:767
FunctionRecordIterator(ArrayRef< FunctionRecord > Records_, StringRef Filename="", ArrayRef< unsigned > RecordIndices_={})
Definition CoverageMapping.h:778
FunctionRecordIterator & operator++()
Definition CoverageMapping.h:801
bool operator==(const FunctionRecordIterator &RHS) const
Definition CoverageMapping.h:795
FunctionRecordIterator()
Definition CoverageMapping.h:793
const FunctionRecord & operator*() const
Definition CoverageMapping.h:799
InstantiationGroup(const InstantiationGroup &)=delete
unsigned getLine() const
Get the line where the common function was defined.
Definition CoverageMapping.h:905
unsigned getColumn() const
Get the column where the common function was defined.
Definition CoverageMapping.h:908
bool hasName() const
Check if the instantiations in this group have a common mangled name.
Definition CoverageMapping.h:911
size_t size() const
Get the number of instantiations in this group.
Definition CoverageMapping.h:902
ArrayRef< const FunctionRecord * > getInstantiations() const
Get the instantiations in this group.
Definition CoverageMapping.h:933
friend class CoverageMapping
Definition CoverageMapping.h:887
uint64_t getTotalExecutionCount() const
Get the total execution count of all instantiations in this group.
Definition CoverageMapping.h:925
InstantiationGroup(InstantiationGroup &&)=default
StringRef getName() const
Get the common mangled name for instantiations in this group.
Definition CoverageMapping.h:919
An iterator over the LineCoverageStats objects for lines described by a CoverageData instance.
Definition CoverageMapping.h:1142
LineCoverageIterator(const CoverageData &CD)
Definition CoverageMapping.h:1144
const LineCoverageStats & operator*() const
Definition CoverageMapping.h:1157
bool operator==(const LineCoverageIterator &R) const
Definition CoverageMapping.h:1153
LineCoverageIterator getEnd() const
Definition CoverageMapping.h:1161
LLVM_ABI LineCoverageIterator & operator++()
LineCoverageIterator(const CoverageData &CD, unsigned Line)
Definition CoverageMapping.h:1147
Coverage statistics for a single line.
Definition CoverageMapping.h:1106
bool hasMultipleRegions() const
Definition CoverageMapping.h:1124
unsigned getLine() const
Definition CoverageMapping.h:1128
const CoverageSegment * getWrappedSegment() const
Definition CoverageMapping.h:1134
uint64_t getExecutionCount() const
Definition CoverageMapping.h:1122
ArrayRef< const CoverageSegment * > getLineSegments() const
Definition CoverageMapping.h:1130
friend class LineCoverageIterator
Definition CoverageMapping.h:1114
bool isMapped() const
Definition CoverageMapping.h:1126
auto getIndex() const
Equivalent to buildTestVector's Index.
Definition CoverageMapping.h:420
CondState operator[](int I) const
Emulate RHS SmallVector::operator[].
Definition CoverageMapping.h:414
TestVector(unsigned N)
~DontCare
Definition CoverageMapping.h:411
void set(int I, CondState Val)
Set the condition Val at position I.
Definition CoverageMapping.h:424
auto getDifferences(const TestVector &B) const
For each element:
Definition CoverageMapping.h:442
void push_back(CondState Val)
Emulate SmallVector::push_back.
Definition CoverageMapping.h:430
static constexpr auto HardMaxTVs
Hard limit of test vectors.
Definition CoverageMapping.h:670
LLVM_ABI TVIdxBuilder(const SmallVectorImpl< ConditionIDs > &NextIDs, int Offset=0)
Calculate and assign Indices.
SmallVector< std::array< int, 2 > > Indices
Output: Index for TestVectors bitmap (These are not CondIDs)
Definition CoverageMapping.h:663
int NumTestVectors
Output: The number of test vectors.
Definition CoverageMapping.h:667
SmallVector< MCDCNode > SavedNodes
This is no longer needed after the assignment.
Definition CoverageMapping.h:659
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
BuildIDFetcher searches local cache directories for debug info.
This class implements an extremely fast bulk output stream that can only output to a stream.
The virtual file system interface.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
@ C
The default llvm calling convention, compatible with C.
This namespace defines accessors shared by different versions of coverage mapping records.
Definition CoverageMapping.h:1213
uint64_t getFuncNameRef(const FuncRecordTy *Record)
Return the function lookup key. The value is considered opaque.
Definition CoverageMapping.h:1229
StringRef getCoverageMappingOutOfLine(const FuncRecordTy *Record, const char *MappingBuf)
Read coverage mapping out-of-line, from MappingBuf.
Definition CoverageMapping.h:1247
uint64_t getDataSize(const FuncRecordTy *Record)
Return the coverage map data size for the function.
Definition CoverageMapping.h:1223
Error getFuncNameViaRef(const FuncRecordTy *Record, InstrProfSymtab &ProfileNames, StringRef &FuncName)
Return the PGO name of the function.
Definition CoverageMapping.h:1236
std::pair< const char *, const FuncRecordTy * > advanceByOneOutOfLine(const FuncRecordTy *Record, const char *MappingBuf)
Advance to the next out-of-line coverage mapping and its associated function record.
Definition CoverageMapping.h:1256
uint64_t getFuncHash(const FuncRecordTy *Record)
Return the structural hash associated with the function.
Definition CoverageMapping.h:1217
Definition CoverageMapping.h:633
static auto & getParams(MaybeConstMCDCParameters &MCDCParams)
Check and get underlying params in MCDCParams.
std::variant< std::monostate, DecisionParameters, BranchParameters > Parameters
The type of MC/DC-specific parameters.
std::array< ConditionID, 2 > ConditionIDs
Definition CoverageMapping.h:59
CovMapVersion
Definition CoverageMapping.h:1437
@ Version5
Definition CoverageMapping.h:1449
@ Version4
Definition CoverageMapping.h:1447
@ Version2
Definition CoverageMapping.h:1442
@ Version7
Definition CoverageMapping.h:1454
@ Version3
Definition CoverageMapping.h:1445
@ CurrentVersion
Definition CoverageMapping.h:1456
@ Version1
Definition CoverageMapping.h:1438
@ Version6
Definition CoverageMapping.h:1452
LLVM_ABI const std::error_category & coveragemap_category()
std::error_code make_error_code(coveragemap_error E)
Definition CoverageMapping.h:77
std::pair< unsigned, unsigned > LineColPair
Definition CoverageMapping.h:229
static iterator_range< LineCoverageIterator > getLineCoverageStats(const coverage::CoverageData &CD)
Get a LineCoverageIterator range for the lines described by CD.
Definition CoverageMapping.h:1180
coveragemap_error
Definition CoverageMapping.h:64
@ success
Definition CoverageMapping.h:65
@ unsupported_version
Definition CoverageMapping.h:68
@ eof
Definition CoverageMapping.h:66
@ decompression_failed
Definition CoverageMapping.h:71
@ malformed
Definition CoverageMapping.h:70
@ invalid_or_missing_arch_specifier
Definition CoverageMapping.h:72
@ truncated
Definition CoverageMapping.h:69
@ no_data_found
Definition CoverageMapping.h:67
TestingFormatVersion
Definition CoverageMapping.h:1462
constexpr uint64_t TestingFormatMagic
Definition CoverageMapping.h:1460
value_type byte_swap(value_type value, endianness endian)
This is an optimization pass for GlobalISel generic memory operations.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
uint64_t offsetToAlignedAddr(const void *Addr, Align Alignment)
Returns the necessary adjustment for aligning Addr to Alignment bytes, rounding up.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionAddr VTableAddr Count
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
FunctionAddr VTableAddr Next
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
auto make_second_range(ContainerTy &&c)
Given a container of pairs, return a range over the second elements.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
bool isAddrAligned(Align Lhs, const void *Addr)
Checks that Addr is a multiple of the alignment.
Implement std::hash so that hash_code can be used in STL containers.
static coverage::CounterExpression getTombstoneKey()
Definition CoverageMapping.h:1505
static bool isEqual(const coverage::CounterExpression &LHS, const coverage::CounterExpression &RHS)
Definition CoverageMapping.h:1519
static unsigned getHashValue(const coverage::CounterExpression &V)
Definition CoverageMapping.h:1513
static coverage::CounterExpression getEmptyKey()
Definition CoverageMapping.h:1497
An information struct used to provide DenseMap with the various necessary components for a given valu...
Associates a source range with an execution count.
Definition CoverageMapping.h:373
bool FalseFolded
Definition CoverageMapping.h:377
bool TrueFolded
Definition CoverageMapping.h:376
CountedRegion(const CounterMappingRegion &R, uint64_t ExecutionCount, uint64_t FalseExecutionCount)
Definition CoverageMapping.h:383
CountedRegion(const CounterMappingRegion &R, uint64_t ExecutionCount)
Definition CoverageMapping.h:379
uint64_t ExecutionCount
Definition CoverageMapping.h:374
uint64_t FalseExecutionCount
Definition CoverageMapping.h:375
A Counter expression is a value that represents an arithmetic operation with two counters.
Definition CoverageMapping.h:165
CounterExpression(ExprKind Kind, Counter LHS, Counter RHS)
Definition CoverageMapping.h:170
Counter RHS
Definition CoverageMapping.h:168
Counter LHS
Definition CoverageMapping.h:168
ExprKind
Definition CoverageMapping.h:166
@ Add
Definition CoverageMapping.h:166
@ Subtract
Definition CoverageMapping.h:166
ExprKind Kind
Definition CoverageMapping.h:167
A Counter mapping region associates a source range with a specific counter.
Definition CoverageMapping.h:232
bool isBranch() const
Definition CoverageMapping.h:286
LineColPair endLoc() const
Definition CoverageMapping.h:369
unsigned ColumnEnd
Definition CoverageMapping.h:282
const auto & getDecisionParams() const
Definition CoverageMapping.h:272
CounterMappingRegion(const mcdc::DecisionParameters &MCDCParams, unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd, RegionKind Kind)
Definition CoverageMapping.h:307
static CounterMappingRegion makeExpansion(unsigned FileID, unsigned ExpandedFileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
Definition CoverageMapping.h:323
static CounterMappingRegion makeGapRegion(Counter Count, unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
Definition CoverageMapping.h:338
CounterMappingRegion(Counter Count, unsigned FileID, unsigned ExpandedFileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd, RegionKind Kind)
Definition CoverageMapping.h:290
static CounterMappingRegion makeRegion(Counter Count, unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
Definition CoverageMapping.h:316
static CounterMappingRegion makeDecisionRegion(const mcdc::DecisionParameters &MCDCParams, unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
Definition CoverageMapping.h:358
Counter FalseCount
Secondary Counter used for Branch Regions (FalseCount).
Definition CoverageMapping.h:267
static CounterMappingRegion makeSkipped(unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
Definition CoverageMapping.h:331
Counter Count
Primary Counter that is also used for Branch Regions (TrueCount).
Definition CoverageMapping.h:264
unsigned FileID
Definition CoverageMapping.h:280
unsigned ExpandedFileID
Definition CoverageMapping.h:281
unsigned ColumnStart
Definition CoverageMapping.h:282
LineColPair startLoc() const
Definition CoverageMapping.h:365
const auto & getBranchParams() const
Definition CoverageMapping.h:276
unsigned LineEnd
Definition CoverageMapping.h:282
RegionKind Kind
Definition CoverageMapping.h:284
static CounterMappingRegion makeBranchRegion(Counter Count, Counter FalseCount, unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd, const mcdc::Parameters &MCDCParams=std::monostate())
Definition CoverageMapping.h:345
unsigned LineStart
Definition CoverageMapping.h:282
mcdc::Parameters MCDCParams
Parameters used for Modified Condition/Decision Coverage.
Definition CoverageMapping.h:270
RegionKind
Definition CoverageMapping.h:233
@ ExpansionRegion
An ExpansionRegion represents a file expansion region that associates a source range with the expansi...
Definition CoverageMapping.h:240
@ MCDCDecisionRegion
A DecisionRegion represents a top-level boolean expression and is associated with a variable length b...
Definition CoverageMapping.h:257
@ MCDCBranchRegion
A Branch Region can be extended to include IDs to facilitate MC/DC.
Definition CoverageMapping.h:260
@ SkippedRegion
A SkippedRegion represents a source range with code that was skipped by a preprocessor or similar mea...
Definition CoverageMapping.h:244
@ GapRegion
A GapRegion is like a CodeRegion, but its count is only set as the line execution count when its the ...
Definition CoverageMapping.h:248
@ BranchRegion
A BranchRegion represents leaf-level boolean expressions and is associated with two counters,...
Definition CoverageMapping.h:253
@ CodeRegion
A CodeRegion associates some code with a counter.
Definition CoverageMapping.h:235
A Counter is an abstract value that describes how to compute the execution count for a region of code...
Definition CoverageMapping.h:108
static const unsigned EncodingTagBits
Definition CoverageMapping.h:112
bool isZero() const
Definition CoverageMapping.h:128
static Counter getZero()
Return the counter that represents the number zero.
Definition CoverageMapping.h:149
static Counter getCounter(unsigned CounterId)
Return the counter that corresponds to a specific profile counter.
Definition CoverageMapping.h:152
friend bool operator==(const Counter &LHS, const Counter &RHS)
Definition CoverageMapping.h:136
unsigned getCounterID() const
Definition CoverageMapping.h:132
CounterKind
The CounterExpression kind (Add or Subtract) is encoded in bit 0 next to the CounterKind.
Definition CoverageMapping.h:111
@ Expression
Definition CoverageMapping.h:111
@ CounterValueReference
Definition CoverageMapping.h:111
@ Zero
Definition CoverageMapping.h:111
unsigned getExpressionID() const
Definition CoverageMapping.h:134
static const unsigned EncodingCounterTagAndExpansionRegionTagBits
Definition CoverageMapping.h:114
CounterKind getKind() const
Definition CoverageMapping.h:126
bool isExpression() const
Definition CoverageMapping.h:130
friend bool operator!=(const Counter &LHS, const Counter &RHS)
Definition CoverageMapping.h:140
friend bool operator<(const Counter &LHS, const Counter &RHS)
Definition CoverageMapping.h:144
static const unsigned EncodingTagMask
Definition CoverageMapping.h:113
static Counter getExpression(unsigned ExpressionId)
Return the counter that corresponds to a specific addition counter expression.
Definition CoverageMapping.h:158
Definition CoverageMapping.h:1264
FunctionAddr VTableAddr Count
Definition CoverageMapping.h:139
ConstantInt::get(llvm::Type::getInt64Ty(Ctx), Inc->getHash() ->getZExtValue())) INSTR_PROF_DATA(const IntPtrT
std::pair< const char *, const ThisT * > advanceByOne(const char *MappingBuf) const
Definition CoverageMapping.h:1034
StringRef getCoverageMapping(const char *MappingBuf) const
Definition CoverageMapping.h:1043
uint64_t getFuncHash() const
Definition CoverageMapping.h:1007
FunctionAddr VTableAddr uintptr_t uintptr_t NamePtr
Definition CoverageMapping.h:256
uint64_t getFilenamesRef() const
Definition CoverageMapping.h:1038
Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const
Return the PGO name of the function.
Definition CoverageMapping.h:1022
CovMapFunctionRecordV1< IntPtrT > ThisT
Definition CoverageMapping.h:1265
FunctionAddr VTableAddr uintptr_t uintptr_t NameSize
Definition CoverageMapping.h:258
FunctionAddr ConstantInt::get(llvm::Type::getInt32Ty(Ctx), NumBitmapBytes)) INSTR_PROF_VTABLE_DATA(const uint64_t
IntPtrT getFuncNameRef() const
Return function lookup key. The value is consider opaque.
Definition CoverageMapping.h:1016
uint64_t getDataSize() const
Definition CoverageMapping.h:1011
Definition CoverageMapping.h:1315
uint64_t getFilenamesRef() const
Definition CoverageMapping.h:1031
FunctionAddr VTableAddr Count
Definition CoverageMapping.h:139
Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const
Definition CoverageMapping.h:1020
uint64_t getDataSize() const
Definition CoverageMapping.h:1011
std::pair< const char *, const ThisT * > advanceByOne(const char *MappingBuf) const
Definition CoverageMapping.h:1027
StringRef getCoverageMapping(const char *MappingBuf) const
Definition CoverageMapping.h:1036
uint64_t getFuncHash() const
Definition CoverageMapping.h:1007
CovMapFunctionRecordV2 ThisT
Definition CoverageMapping.h:1316
uint64_t getFuncNameRef() const
Definition CoverageMapping.h:1015
Definition CoverageMapping.h:1359
uint64_t getFuncHash() const
Definition CoverageMapping.h:1007
FunctionAddr VTableAddr Next
Definition CoverageMapping.h:141
FunctionAddr VTableAddr uintptr_t uintptr_t FilenamesRef
Definition CoverageMapping.h:274
FunctionAddr VTableAddr uintptr_t uintptr_t CoverageMapping
Definition CoverageMapping.h:280
std::pair< const char *, const CovMapFunctionRecordV3 * > advanceByOne(const char *) const
Definition CoverageMapping.h:1041
uint64_t getFuncNameRef() const
Definition CoverageMapping.h:1015
CovMapFunctionRecordV3 ThisT
Definition CoverageMapping.h:1360
StringRef getCoverageMapping(const char *) const
Read the inline coverage mapping.
Definition CoverageMapping.h:1033
uint64_t getFilenamesRef() const
Get the filename set reference.
Definition CoverageMapping.h:1026
Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const
Definition CoverageMapping.h:1020
uint64_t getDataSize() const
Definition CoverageMapping.h:1011
IntPtrT NameRefType
Definition CoverageMapping.h:1490
CovMapFunctionRecordV1< IntPtrT > CovMapFuncRecordType
Definition CoverageMapping.h:1489
CovMapFunctionRecordV2 CovMapFuncRecordType
Definition CoverageMapping.h:1484
uint64_t NameRefType
Definition CoverageMapping.h:1485
uint64_t NameRefType
Definition CoverageMapping.h:1480
CovMapFunctionRecordV2 CovMapFuncRecordType
Definition CoverageMapping.h:1479
Definition CoverageMapping.h:1473
CovMapFunctionRecordV3 CovMapFuncRecordType
Definition CoverageMapping.h:1474
uint64_t NameRefType
Definition CoverageMapping.h:1475
Coverage mapping information for a single function.
The execution count information starting at a point in a file.
Definition CoverageMapping.h:849
CoverageSegment(unsigned Line, unsigned Col, bool IsRegionEntry)
Definition CoverageMapping.h:863
bool HasCount
When false, the segment was uninstrumented or skipped.
Definition CoverageMapping.h:857
unsigned Col
The column where this segment begins.
Definition CoverageMapping.h:853
friend bool operator==(const CoverageSegment &L, const CoverageSegment &R)
Definition CoverageMapping.h:873
bool IsRegionEntry
Whether this enters a new region or returns to a previous count.
Definition CoverageMapping.h:859
uint64_t Count
The execution count, or zero if no count was recorded.
Definition CoverageMapping.h:855
unsigned Line
The line where this segment begins.
Definition CoverageMapping.h:851
CoverageSegment(unsigned Line, unsigned Col, uint64_t Count, bool IsRegionEntry, bool IsGapRegion=false, bool IsBranchRegion=false)
Definition CoverageMapping.h:867
bool IsGapRegion
Whether this enters a gap region.
Definition CoverageMapping.h:861
Coverage information for a macro expansion or included file.
Definition CoverageMapping.h:832
const CountedRegion & Region
The region that expands to this record.
Definition CoverageMapping.h:836
unsigned FileID
The abstract file this expansion covers.
Definition CoverageMapping.h:834
ExpansionRecord(const CountedRegion &Region, const FunctionRecord &Function)
Definition CoverageMapping.h:840
const FunctionRecord & Function
Coverage for the expansion.
Definition CoverageMapping.h:838
Code coverage information for a single function.
Definition CoverageMapping.h:716
std::vector< CountedRegion > CountedBranchRegions
Branch Regions in the function along with their counts.
Definition CoverageMapping.h:729
std::string Name
Raw function name.
Definition CoverageMapping.h:718
std::vector< CountedRegion > CountedRegions
Regions in the function along with their counts.
Definition CoverageMapping.h:727
FunctionRecord & operator=(FunctionRecord &&)=default
void pushMCDCRecord(MCDCRecord &&Record)
Definition CoverageMapping.h:741
std::vector< MCDCRecord > MCDCRecords
MCDC Records record a DecisionRegion and associated BranchRegions.
Definition CoverageMapping.h:731
std::vector< std::string > Filenames
Mapping from FileID (i.e.
Definition CoverageMapping.h:725
FunctionRecord(FunctionRecord &&FR)=default
FunctionRecord(StringRef Name, ArrayRef< StringRef > Filenames)
Definition CoverageMapping.h:735
uint64_t ExecutionCount
The number of times this function was executed.
Definition CoverageMapping.h:733
void pushRegion(CounterMappingRegion Region, uint64_t Count, uint64_t FalseCount)
Definition CoverageMapping.h:745
MCDC Record grouping all information together.
Definition CoverageMapping.h:391
std::pair< unsigned, unsigned > TVRowPair
Definition CoverageMapping.h:454
MCDCRecord(const CounterMappingRegion &Region, TestVectors &&TV, BoolVector &&Folded, CondIDMap &&PosToID, LineColPairMap &&CondLoc)
Definition CoverageMapping.h:468
float getPercentCovered() const
Definition CoverageMapping.h:536
std::string getConditionCoverageString(unsigned Condition)
Definition CoverageMapping.h:614
std::pair< unsigned, unsigned > getDecisions() const
Return the number of True and False decisions for all executed test vectors.
Definition CoverageMapping.h:500
std::string getConditionHeaderString(unsigned Condition)
Definition CoverageMapping.h:552
unsigned getNumTestVectors() const
Definition CoverageMapping.h:483
llvm::SmallVector< std::pair< TestVector, CondState > > TestVectors
Definition CoverageMapping.h:452
LLVM_ABI void findIndependencePairs()
std::string getTestVectorString(unsigned TestVectorIndex)
Definition CoverageMapping.h:576
llvm::DenseMap< unsigned, unsigned > CondIDMap
Definition CoverageMapping.h:456
llvm::DenseMap< unsigned, LineColPair > LineColPairMap
Definition CoverageMapping.h:457
TVRowPair getConditionIndependencePair(unsigned Condition)
Return the Independence Pair that covers the given condition.
Definition CoverageMapping.h:530
bool isConditionIndependencePairCovered(unsigned Condition) const
Determine whether a given condition (indicated by Condition) is covered by an Independence Pair.
Definition CoverageMapping.h:518
CondState
CondState represents the evaluation of a condition in an executed test vector, which can be True or F...
Definition CoverageMapping.h:398
@ MCDC_DontCare
Definition CoverageMapping.h:398
@ MCDC_True
Definition CoverageMapping.h:398
@ MCDC_False
Definition CoverageMapping.h:398
std::string getTestVectorHeaderString() const
Definition CoverageMapping.h:560
CondState getTVCondition(unsigned TestVectorIndex, unsigned Condition)
Return the evaluation of a condition (indicated by Condition) in an executed test vector (indicated b...
Definition CoverageMapping.h:494
unsigned getNumConditions() const
Definition CoverageMapping.h:480
std::array< BitVector, 2 > BoolVector
Definition CoverageMapping.h:453
const CounterMappingRegion & getDecisionRegion() const
Definition CoverageMapping.h:479
llvm::DenseMap< unsigned, TVRowPair > TVPairMap
Definition CoverageMapping.h:455
CondState getTVResult(unsigned TestVectorIndex)
Return the Result evaluation for an executed test vector.
Definition CoverageMapping.h:509
bool isCondFolded(unsigned Condition) const
Definition CoverageMapping.h:484
Definition CoverageMapping.h:650
int InCount
Definition CoverageMapping.h:651
ConditionIDs NextIDs
Number of accumulated paths (>= 1)
Definition CoverageMapping.h:653
int Width
Reference count; temporary use.
Definition CoverageMapping.h:652