14#ifndef LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H
15#define LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H
44#include <system_error>
81 : Err(Err), Msg(ErrStr.str()) {
85 std::string message()
const override;
118 Counter(CounterKind Kind,
unsigned ID) : Kind(Kind), ID(ID) {}
142 return std::tie(
LHS.Kind,
LHS.ID) < std::tie(
RHS.Kind,
RHS.ID);
175 std::vector<CounterExpression> Expressions;
192 Term(
unsigned CounterID,
int Factor)
193 : CounterID(CounterID), Factor(Factor) {}
417 auto getIndex()
const {
return Values.getData()[0]; }
430 assert(Values.size() == Visited.size());
440 const auto &
A = *
this;
460 std::optional<TVPairMap> IndependencePairs;
466 unsigned DisplayRowNumber)
const {
467 std::ostringstream OS;
470 OS <<
" " << DisplayRowNumber <<
" { ";
471 for (
unsigned Condition = 0; Condition < NumConditions; Condition++) {
475 auto It = PosToID.find(Condition);
476 assert(It != PosToID.end() &&
"Ordinal without CondID mapping");
477 switch (Vec[It->second]) {
489 if (Condition != NumConditions - 1)
507 : Region(Region), TV(
std::
move(TV)),
508 NotExecutedTV(
std::
move(NotExecutedTV)), Folded(
std::
move(Folded)),
519 return Region.getDecisionParams().NumConditions;
525 return Folded[
false][Condition] || Folded[
true][Condition];
535 return TV[TestVectorIndex].first[PosToID[Condition]];
539 unsigned Condition) {
540 return NotExecutedTV[NotExecutedIndex].first[PosToID[Condition]];
546 const unsigned TrueDecisions =
549 return {TrueDecisions, TV.size() - TrueDecisions};
555 return TV[TestVectorIndex].second;
559 return NotExecutedTV[NotExecutedIndex].second;
568 assert(IndependencePairs);
569 auto It = PosToID.find(Condition);
570 assert(It != PosToID.end() &&
"Condition ID without an Ordinal mapping");
571 return IndependencePairs->contains(It->second);
581 assert(IndependencePairs);
582 return (*IndependencePairs)[PosToID[Condition]];
587 unsigned Covered = 0;
598 return (
static_cast<double>(Covered) /
static_cast<double>(
Total)) * 100.0;
602 std::ostringstream OS;
603 const auto &[Line, Col] = CondLoc[Condition];
604 OS <<
"Condition C" << Condition + 1 <<
" --> (" << Line <<
":" << Col
610 std::ostringstream OS;
616 for (
unsigned I = 0;
I < NumConditions;
I++) {
618 if (
I != NumConditions - 1)
627 "TestVector index out of bounds!");
628 const auto &[Vec, Res] = TV[TestVectorIndex];
629 return formatTestVectorRow(Vec, Res, TestVectorIndex + 1);
634 "Not-executed test vector index out of bounds!");
635 const auto &[Vec, Res] = NotExecutedTV[NotExecutedIndex];
636 return formatTestVectorRow(Vec, Res,
642 "Condition index is out of bounds!");
643 std::ostringstream OS;
645 OS <<
" C" << Condition + 1 <<
"-Pair: ";
647 OS <<
"constant folded\n";
650 OS <<
"covered: (" << rows.first <<
",";
651 OS << rows.second <<
")\n";
653 OS <<
"not covered\n";
719 : Expressions(Expressions), CounterValues(CounterValues) {}
793 std::forward_iterator_tag, FunctionRecord> {
807 : Records(Records_), RecordIndices(RecordIndices_),
808 CurrentIndex(RecordIndices.begin()),
811 Current(CurrentIndex == RecordIndices.end() ? Records.begin()
812 : &Records[*CurrentIndex]),
815 "If `Filename` is specified, `RecordIndices` must also be provided");
822 return Current ==
RHS.Current && Filename ==
RHS.Filename;
835 if (RecordIndices.
empty()) {
837 assert(Current != Records.
end() &&
"incremented past end");
842 assert(CurrentIndex != RecordIndices.
end() &&
"incremented past end");
844 if (CurrentIndex == RecordIndices.
end()) {
845 Current = Records.
end();
847 Current = &Records[*CurrentIndex];
895 bool IsBranchRegion =
false)
900 return std::tie(L.Line, L.Col, L.Count, L.HasCount, L.IsRegionEntry,
901 L.IsGapRegion) == std::tie(R.Line, R.Col, R.Count,
902 R.HasCount, R.IsRegionEntry,
912class InstantiationGroup {
917 std::vector<const FunctionRecord *> Instantiations;
919 InstantiationGroup(
unsigned Line,
unsigned Col,
920 std::vector<const FunctionRecord *> Instantiations)
921 : Line(Line), Col(Col), Instantiations(
std::
move(Instantiations)) {}
928 size_t size()
const {
return Instantiations.size(); }
938 for (
unsigned I = 1,
E = Instantiations.size();
I <
E; ++
I)
939 if (Instantiations[
I]->Name != Instantiations[0]->Name)
946 assert(
hasName() &&
"Instantiations don't have a shared name");
947 return Instantiations[0]->Name;
954 Count +=
F->ExecutionCount;
960 return Instantiations;
996 std::vector<CoverageSegment>::const_iterator
begin()
const {
1000 std::vector<CoverageSegment>::const_iterator
end()
const {
1020class CoverageMapping {
1022 std::vector<FunctionRecord> Functions;
1024 std::vector<std::pair<std::string, uint64_t>> FuncHashMismatches;
1026 std::optional<bool> SingleByteCoverage;
1028 CoverageMapping() =
default;
1031 static Error loadFromReaders(
1032 ArrayRef<std::unique_ptr<CoverageMappingReader>> CoverageReaders,
1033 std::optional<std::reference_wrapper<IndexedInstrProfReader>>
1035 CoverageMapping &Coverage);
1040 std::optional<std::reference_wrapper<IndexedInstrProfReader>>
1042 CoverageMapping &Coverage,
bool &DataFound,
1046 Error loadFunctionRecord(
1048 const std::optional<std::reference_wrapper<IndexedInstrProfReader>>
1060 CoverageMapping &
operator=(
const CoverageMapping &) =
delete;
1064 load(
ArrayRef<std::unique_ptr<CoverageMappingReader>> CoverageReaders,
1065 std::optional<std::reference_wrapper<IndexedInstrProfReader>>
1076 bool CheckBinaryIDs =
false);
1089 return FuncHashMismatches;
1122 getImpreciseRecordIndicesForFilename(
Filename)),
1130 LLVM_ABI std::vector<InstantiationGroup>
1135class LineCoverageStats {
1137 bool HasMultipleRegions;
1144 LineCoverageStats() =
default;
1160 return LineSegments;
1170 std::forward_iterator_tag,
1171 const LineCoverageStats> {
1177 : CD(CD), WrappedSegment(nullptr), Next(CD.begin()), Ended(
false),
1183 return &CD == &R.CD && Next == R.Next && Ended == R.Ended;
1192 EndIt.Next = CD.
end();
1200 std::vector<CoverageSegment>::const_iterator
Next;
1211 auto End = Begin.getEnd();
1245template <
class FuncRecordTy, llvm::endianness Endian>
1251template <
class FuncRecordTy, llvm::endianness Endian>
1257template <
class FuncRecordTy, llvm::endianness Endian>
1264template <
class FuncRecordTy, llvm::endianness Endian>
1275template <
class FuncRecordTy, llvm::endianness Endian>
1277 const char *MappingBuf) {
1283template <
class FuncRecordTy, llvm::endianness Endian>
1284std::pair<const char *, const FuncRecordTy *>
1292template <
class IntPtrT>
1297#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
1300 CovMapFunctionRecordV1() =
delete;
1311 template <llvm::endianness Endian> IntPtrT
getFuncNameRef()
const {
1316 template <llvm::endianness Endian>
1317 Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName)
const {
1320 FuncName = ProfileNames.getFuncName(NameRef, NameS);
1321 if (NameS && FuncName.empty())
1323 "function name is empty");
1327 template <llvm::endianness Endian>
1328 std::pair<const char *, const ThisT *>
1337 template <llvm::endianness Endian>
1348#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
1351 CovMapFunctionRecordV2() =
delete;
1365 template <llvm::endianness Endian>
1366 Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName)
const {
1371 template <llvm::endianness Endian>
1372 std::pair<const char *, const ThisT *>
1381 template <llvm::endianness Endian>
1392#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
1395 CovMapFunctionRecordV3() =
delete;
1409 template <llvm::endianness Endian>
1410 Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName)
const {
1422 template <llvm::endianness Endian>
1429 template <llvm::endianness Endian>
1430 std::pair<const char *, const CovMapFunctionRecordV3 *>
1433 const char *
Next = ((
const char *)
this) +
sizeof(CovMapFunctionRecordV3) -
1438 return {
nullptr,
reinterpret_cast<const CovMapFunctionRecordV3 *
>(
Next)};
1445#define COVMAP_HEADER(Type, LLVMType, Name, Init) Type Name;
1447 template <llvm::endianness Endian>
uint32_t getNRecords()
const {
1451 template <llvm::endianness Endian> uint32_t getFilenamesSize()
const {
1455 template <llvm::endianness Endian> uint32_t getCoverageSize()
const {
1459 template <llvm::endianness Endian> uint32_t getVersion()
const {
1527 return static_cast<unsigned>(
1528 hash_combine(V.Kind, V.LHS.getKind(), V.LHS.getCounterID(),
1529 V.RHS.getKind(), V.RHS.getCounterID()));
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< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
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
static constexpr StringLiteral Filename
Contains the forward declaration for vfs::FileSystem, as well as the IntrusiveRefCntPtrInfo specializ...
Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
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.
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.
ArrayRef< CounterExpression > getExpressions() const
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.
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)
void dump(const Counter &C) const
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_)
LLVM_ABI unsigned getMaxCounterID(const Counter &C) const
CounterMappingContext(ArrayRef< CounterExpression > Expressions, ArrayRef< uint64_t > CounterValues={})
LLVM_ABI void dump(const Counter &C, raw_ostream &OS) const
Coverage information to be processed or displayed.
CoverageData(CoverageData &&RHS)=default
std::vector< CountedRegion > BranchRegions
bool getSingleByteCoverage() const
ArrayRef< ExpansionRecord > getExpansions() const
Expansions that can be further processed.
std::vector< CoverageSegment > Segments
std::vector< ExpansionRecord > Expansions
ArrayRef< CountedRegion > getBranches() const
Branches that can be further processed.
std::vector< CoverageSegment >::const_iterator begin() const
Get an iterator over the coverage segments for this object.
std::vector< CoverageSegment >::const_iterator end() const
friend class CoverageMapping
std::vector< MCDCRecord > MCDCRecords
StringRef getFilename() const
Get the name of the file this data covers.
ArrayRef< MCDCRecord > getMCDCRecords() const
MCDC Records that can be further processed.
CoverageData(bool Single, StringRef Filename)
std::string message() const override
Return the error message as a string.
CoverageMapError(coveragemap_error Err, const Twine &ErrStr=Twine())
void log(raw_ostream &OS) const override
Print an error message to an output stream.
coveragemap_error get() const
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
const std::string & getMessage() const
unsigned getMismatchedCount() const
The number of functions that couldn't have their profiles mapped.
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...
iterator_range< FunctionRecordIterator > getCoveredFunctions(StringRef Filename) const
Gets all of the functions in a particular file.
iterator_range< FunctionRecordIterator > getCoveredFunctions() const
Gets all of the functions covered by this profile.
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.
FunctionRecordIterator(ArrayRef< FunctionRecord > Records_, StringRef Filename="", ArrayRef< unsigned > RecordIndices_={})
FunctionRecordIterator & operator++()
bool operator==(const FunctionRecordIterator &RHS) const
const FunctionRecord & operator*() const
InstantiationGroup(const InstantiationGroup &)=delete
unsigned getLine() const
Get the line where the common function was defined.
unsigned getColumn() const
Get the column where the common function was defined.
bool hasName() const
Check if the instantiations in this group have a common mangled name.
size_t size() const
Get the number of instantiations in this group.
ArrayRef< const FunctionRecord * > getInstantiations() const
Get the instantiations in this group.
friend class CoverageMapping
uint64_t getTotalExecutionCount() const
Get the total execution count of all instantiations in this group.
InstantiationGroup(InstantiationGroup &&)=default
StringRef getName() const
Get the common mangled name for instantiations in this group.
An iterator over the LineCoverageStats objects for lines described by a CoverageData instance.
LineCoverageIterator(const CoverageData &CD)
const LineCoverageStats & operator*() const
bool operator==(const LineCoverageIterator &R) const
LineCoverageIterator getEnd() const
LLVM_ABI LineCoverageIterator & operator++()
LineCoverageIterator(const CoverageData &CD, unsigned Line)
Coverage statistics for a single line.
bool hasMultipleRegions() const
const CoverageSegment * getWrappedSegment() const
uint64_t getExecutionCount() const
ArrayRef< const CoverageSegment * > getLineSegments() const
friend class LineCoverageIterator
Emulate SmallVector<CondState> with a pair of BitVector.
auto getIndex() const
Equivalent to buildTestVector's Index.
CondState operator[](int I) const
Emulate RHS SmallVector::operator[].
TestVector(unsigned N)
~DontCare
void set(int I, CondState Val)
Set the condition Val at position I.
auto getDifferences(const TestVector &B) const
For each element:
void push_back(CondState Val)
Emulate SmallVector::push_back.
static constexpr auto HardMaxTVs
Hard limit of test vectors.
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)
int NumTestVectors
Output: The number of test vectors.
SmallVector< MCDCNode > SavedNodes
This is no longer needed after the assignment.
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.
constexpr size_t NameSize
This namespace defines accessors shared by different versions of coverage mapping records.
uint64_t getFuncNameRef(const FuncRecordTy *Record)
Return the function lookup key. The value is considered opaque.
StringRef getCoverageMappingOutOfLine(const FuncRecordTy *Record, const char *MappingBuf)
Read coverage mapping out-of-line, from MappingBuf.
uint64_t getDataSize(const FuncRecordTy *Record)
Return the coverage map data size for the function.
Error getFuncNameViaRef(const FuncRecordTy *Record, InstrProfSymtab &ProfileNames, StringRef &FuncName)
Return the PGO name of the function.
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.
uint64_t getFuncHash(const FuncRecordTy *Record)
Return the structural hash associated with the function.
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
LLVM_ABI const std::error_category & coveragemap_category()
std::error_code make_error_code(coveragemap_error E)
std::pair< unsigned, unsigned > LineColPair
static iterator_range< LineCoverageIterator > getLineCoverageStats(const coverage::CoverageData &CD)
Get a LineCoverageIterator range for the lines described by CD.
@ invalid_or_missing_arch_specifier
constexpr uint64_t TestingFormatMagic
value_type byte_swap(value_type value, endianness endian)
Swap the bytes of value to match the given endianness.
This is an optimization pass for GlobalISel generic memory operations.
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.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
constexpr NextUseDistance max(NextUseDistance A, NextUseDistance B)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
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.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
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 bool isEqual(const coverage::CounterExpression &LHS, const coverage::CounterExpression &RHS)
static unsigned getHashValue(const coverage::CounterExpression &V)
An information struct used to provide DenseMap with the various necessary components for a given valu...
Associates a source range with an execution count.
CountedRegion(const CounterMappingRegion &R, uint64_t ExecutionCount, uint64_t FalseExecutionCount)
CountedRegion(const CounterMappingRegion &R, uint64_t ExecutionCount)
uint64_t FalseExecutionCount
A Counter expression is a value that represents an arithmetic operation with two counters.
CounterExpression(ExprKind Kind, Counter LHS, Counter RHS)
A Counter mapping region associates a source range with a specific counter.
LineColPair endLoc() const
const auto & getDecisionParams() const
CounterMappingRegion(const mcdc::DecisionParameters &MCDCParams, unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd, RegionKind Kind)
static CounterMappingRegion makeExpansion(unsigned FileID, unsigned ExpandedFileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
static CounterMappingRegion makeGapRegion(Counter Count, unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
CounterMappingRegion(Counter Count, unsigned FileID, unsigned ExpandedFileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd, RegionKind Kind)
CounterMappingRegion(Counter Count, Counter FalseCount, unsigned FileID, unsigned ExpandedFileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd, RegionKind Kind, const mcdc::Parameters &MCDCParams=std::monostate())
static CounterMappingRegion makeRegion(Counter Count, unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
static CounterMappingRegion makeDecisionRegion(const mcdc::DecisionParameters &MCDCParams, unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
Counter FalseCount
Secondary Counter used for Branch Regions (FalseCount).
static CounterMappingRegion makeSkipped(unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
Counter Count
Primary Counter that is also used for Branch Regions (TrueCount).
LineColPair startLoc() const
const auto & getBranchParams() const
static CounterMappingRegion makeBranchRegion(Counter Count, Counter FalseCount, unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd, const mcdc::Parameters &MCDCParams=std::monostate())
mcdc::Parameters MCDCParams
Parameters used for Modified Condition/Decision Coverage.
@ ExpansionRegion
An ExpansionRegion represents a file expansion region that associates a source range with the expansi...
@ MCDCDecisionRegion
A DecisionRegion represents a top-level boolean expression and is associated with a variable length b...
@ MCDCBranchRegion
A Branch Region can be extended to include IDs to facilitate MC/DC.
@ SkippedRegion
A SkippedRegion represents a source range with code that was skipped by a preprocessor or similar mea...
@ GapRegion
A GapRegion is like a CodeRegion, but its count is only set as the line execution count when its the ...
@ BranchRegion
A BranchRegion represents leaf-level boolean expressions and is associated with two counters,...
@ CodeRegion
A CodeRegion associates some code with a counter.
A Counter is an abstract value that describes how to compute the execution count for a region of code...
static const unsigned EncodingTagBits
static Counter getZero()
Return the counter that represents the number zero.
static Counter getCounter(unsigned CounterId)
Return the counter that corresponds to a specific profile counter.
friend bool operator==(const Counter &LHS, const Counter &RHS)
unsigned getCounterID() const
CounterKind
The CounterExpression kind (Add or Subtract) is encoded in bit 0 next to the CounterKind.
unsigned getExpressionID() const
static const unsigned EncodingCounterTagAndExpansionRegionTagBits
CounterKind getKind() const
bool isExpression() const
friend bool operator!=(const Counter &LHS, const Counter &RHS)
friend bool operator<(const Counter &LHS, const Counter &RHS)
static const unsigned EncodingTagMask
static Counter getExpression(unsigned ExpressionId)
Return the counter that corresponds to a specific addition counter expression.
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
StringRef getCoverageMapping(const char *MappingBuf) const
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr UniformCountersBegin(uintptr_t) UniformCountersBegin -(uintptr_t) DataBegin uint64_t getFuncHash() const
uint64_t getFilenamesRef() const
Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const
Return the PGO name of the function.
CovMapFunctionRecordV1< IntPtrT > ThisT
IntPtrT getFuncNameRef() const
Return function lookup key. The value is consider opaque.
uint64_t getDataSize() const
uint64_t getFilenamesRef() const
Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const
uint64_t getDataSize() const
std::pair< const char *, const ThisT * > advanceByOne(const char *MappingBuf) const
StringRef getCoverageMapping(const char *MappingBuf) const
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr UniformCountersBegin(uintptr_t) UniformCountersBegin -(uintptr_t) DataBegin uint64_t getFuncHash() const
CovMapFunctionRecordV2 ThisT
uint64_t getFuncNameRef() const
std::pair< const char *, const CovMapFunctionRecordV3 * > advanceByOne(const char *) const
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr UniformCountersBegin(uintptr_t) UniformCountersBegin -(uintptr_t) DataBegin uint64_t getFuncHash() const
uint64_t getFuncNameRef() const
CovMapFunctionRecordV3 ThisT
StringRef getCoverageMapping(const char *) const
Read the inline coverage mapping.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
uint64_t getFilenamesRef() const
Get the filename set reference.
Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const
uint64_t getDataSize() const
CovMapFunctionRecordV1< IntPtrT > CovMapFuncRecordType
CovMapFunctionRecordV2 CovMapFuncRecordType
CovMapFunctionRecordV2 CovMapFuncRecordType
CovMapFunctionRecordV3 CovMapFuncRecordType
Coverage mapping information for a single function.
The execution count information starting at a point in a file.
CoverageSegment(unsigned Line, unsigned Col, bool IsRegionEntry)
bool HasCount
When false, the segment was uninstrumented or skipped.
unsigned Col
The column where this segment begins.
friend bool operator==(const CoverageSegment &L, const CoverageSegment &R)
bool IsRegionEntry
Whether this enters a new region or returns to a previous count.
uint64_t Count
The execution count, or zero if no count was recorded.
unsigned Line
The line where this segment begins.
CoverageSegment(unsigned Line, unsigned Col, uint64_t Count, bool IsRegionEntry, bool IsGapRegion=false, bool IsBranchRegion=false)
bool IsGapRegion
Whether this enters a gap region.
Coverage information for a macro expansion or included file.
const CountedRegion & Region
The region that expands to this record.
unsigned FileID
The abstract file this expansion covers.
ExpansionRecord(const CountedRegion &Region, const FunctionRecord &Function)
const FunctionRecord & Function
Coverage for the expansion.
Code coverage information for a single function.
std::vector< CountedRegion > CountedBranchRegions
Branch Regions in the function along with their counts.
std::string Name
Raw function name.
std::vector< CountedRegion > CountedRegions
Regions in the function along with their counts.
FunctionRecord & operator=(FunctionRecord &&)=default
void pushMCDCRecord(MCDCRecord &&Record)
std::vector< MCDCRecord > MCDCRecords
MCDC Records record a DecisionRegion and associated BranchRegions.
std::vector< std::string > Filenames
Mapping from FileID (i.e.
FunctionRecord(FunctionRecord &&FR)=default
FunctionRecord(StringRef Name, ArrayRef< StringRef > Filenames)
uint64_t ExecutionCount
The number of times this function was executed.
void pushRegion(CounterMappingRegion Region, uint64_t Count, uint64_t FalseCount)
MCDC Record grouping all information together.
std::pair< unsigned, unsigned > TVRowPair
MCDCRecord(const CounterMappingRegion &Region, TestVectors &&TV, TestVectors &&NotExecutedTV, BoolVector &&Folded, CondIDMap &&PosToID, LineColPairMap &&CondLoc)
CondState getNotExecutedTVCondition(unsigned NotExecutedIndex, unsigned Condition)
float getPercentCovered() const
CondState getNotExecutedTVResult(unsigned NotExecutedIndex)
std::string getConditionCoverageString(unsigned Condition)
std::pair< unsigned, unsigned > getDecisions() const
Return the number of True and False decisions for all executed test vectors.
std::string getConditionHeaderString(unsigned Condition)
unsigned getNumTestVectors() const
llvm::SmallVector< std::pair< TestVector, CondState > > TestVectors
unsigned getNumNotExecutedTestVectors() const
LLVM_ABI void findIndependencePairs()
std::string getTestVectorString(unsigned TestVectorIndex)
llvm::DenseMap< unsigned, unsigned > CondIDMap
llvm::DenseMap< unsigned, LineColPair > LineColPairMap
TVRowPair getConditionIndependencePair(unsigned Condition)
Return the Independence Pair that covers the given condition.
bool isConditionIndependencePairCovered(unsigned Condition) const
Determine whether a given condition (indicated by Condition) is covered by an Independence Pair.
CondState
CondState represents the evaluation of a condition in an executed test vector, which can be True or F...
std::string getTestVectorHeaderString() const
CondState getTVCondition(unsigned TestVectorIndex, unsigned Condition)
Return the evaluation of a condition (indicated by Condition) in an executed test vector (indicated b...
std::string getNotExecutedTestVectorString(unsigned NotExecutedIndex)
unsigned getNumConditions() const
std::array< BitVector, 2 > BoolVector
const CounterMappingRegion & getDecisionRegion() const
llvm::DenseMap< unsigned, TVRowPair > TVPairMap
CondState getTVResult(unsigned TestVectorIndex)
Return the Result evaluation for an executed test vector.
bool isCondFolded(unsigned Condition) const
ConditionIDs NextIDs
Number of accumulated paths (>= 1)
int Width
Reference count; temporary use.