15 #ifndef LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H
16 #define LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H
37 #include <system_error>
44 class IndexedInstrProfReader;
72 std::string
message()
const override;
117 return LHS.Kind == RHS.Kind && LHS.ID == RHS.ID;
121 return !(LHS == RHS);
125 return std::tie(LHS.Kind, LHS.ID) < std::tie(RHS.Kind, RHS.ID);
151 : Kind(Kind), LHS(LHS), RHS(RHS) {}
159 std::vector<CounterExpression> Expressions;
176 Term(
unsigned CounterID,
int Factor)
177 : CounterID(CounterID), Factor(Factor) {}
228 : Count(Count), FileID(FileID), ExpandedFileID(ExpandedFileID),
229 LineStart(LineStart), ColumnStart(ColumnStart), LineEnd(LineEnd),
230 ColumnEnd(ColumnEnd), Kind(Kind) {}
243 ColumnStart, LineEnd, ColumnEnd,
254 inline std::pair<unsigned, unsigned>
startLoc()
const {
258 inline std::pair<unsigned, unsigned>
endLoc()
const {
280 : Expressions(Expressions), CounterValues(CounterValues) {}
304 : Name(Name), Filenames(Filenames.
begin(), Filenames.
end()) {}
319 std::forward_iterator_tag, FunctionRecord> {
325 void skipOtherFiles();
330 : Records(Records_), Current(Records.
begin()), Filename(Filename) {
337 return Current == RHS.Current && Filename == RHS.Filename;
343 assert(Current != Records.end() &&
"incremented past end");
365 :
FileID(Region.ExpandedFileID), Region(Region), Function(Function) {}
386 IsRegionEntry(IsRegionEntry) {}
391 IsRegionEntry(IsRegionEntry) {}
407 std::string Filename;
408 std::vector<CoverageSegment> Segments;
409 std::vector<ExpansionRecord> Expansions;
419 std::vector<CoverageSegment>::const_iterator
begin()
const {
420 return Segments.begin();
423 std::vector<CoverageSegment>::const_iterator
end()
const {
424 return Segments.end();
427 bool empty()
const {
return Segments.empty(); }
439 std::vector<FunctionRecord> Functions;
440 unsigned MismatchedFunctionCount = 0;
454 load(
ArrayRef<std::unique_ptr<CoverageMappingReader>> CoverageReaders,
495 std::vector<const FunctionRecord *>
516 #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
521 template <support::endianness Endian> uint64_t
getFuncHash()
const {
522 return support::endian::byte_swap<uint64_t, Endian>(FuncHash);
527 return support::endian::byte_swap<uint32_t, Endian>(DataSize);
532 return support::endian::byte_swap<IntPtrT, Endian>(NamePtr);
536 template <support::endianness Endian>
538 IntPtrT NameRef = getFuncNameRef<Endian>();
540 FuncName = ProfileNames.
getFuncName(NameRef, NameS);
541 if (NameS && FuncName.empty())
548 #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
552 template <support::endianness Endian> uint64_t
getFuncHash()
const {
553 return support::endian::byte_swap<uint64_t, Endian>(FuncHash);
558 return support::endian::byte_swap<uint32_t, Endian>(DataSize);
563 return support::endian::byte_swap<uint64_t, Endian>(NameRef);
567 template <support::endianness Endian>
569 uint64_t NameRef = getFuncNameRef<Endian>();
578 #define COVMAP_HEADER(Type, LLVMType, Name, Init) Type Name;
581 return support::endian::byte_swap<uint32_t, Endian>(NRecords);
585 return support::endian::byte_swap<uint32_t, Endian>(FilenamesSize);
589 return support::endian::byte_swap<uint32_t, Endian>(CoverageSize);
593 return support::endian::byte_swap<uint32_t, Endian>(
Version);
624 using namespace coverage;
626 return CounterExpression(CounterExpression::ExprKind::Subtract,
627 Counter::getCounter(~0U),
628 Counter::getCounter(~0U));
632 using namespace coverage;
635 Counter::getCounter(~0U),
636 Counter::getCounter(~0U));
640 return static_cast<unsigned>(
653 #endif // LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H
StringRef getFilename() const
Get the name of the file this data covers.
const_iterator end(StringRef path)
Get end iterator over path.
static coverage::CounterExpression getTombstoneKey()
A symbol table used for function PGO name look-up with keys (such as pointers, md5hash values) to the...
bool operator==(const FunctionRecordIterator &RHS) const
static const unsigned EncodingTagMask
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
static Counter getZero()
Return the counter that represents the number zero.
CoverageMapping & operator=(const CoverageMapping &)=delete
CoverageSegment(unsigned Line, unsigned Col, uint64_t Count, bool IsRegionEntry)
std::vector< const FunctionRecord * > getInstantiations(StringRef Filename) const
Get the list of function instantiations in the file.
static CounterMappingRegion makeSkipped(unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
void setCounts(ArrayRef< uint64_t > Counts)
CoverageSegment(unsigned Line, unsigned Col, bool IsRegionEntry)
Expected< int64_t > evaluate(const Counter &C) const
Return the number of times that a region of code associated with this counter was executed...
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
CoverageData getCoverageForFunction(const FunctionRecord &Function) const
Get the coverage for a particular function.
static bool isEqual(const coverage::CounterExpression &LHS, const coverage::CounterExpression &RHS)
iterator_range< FunctionRecordIterator > getCoveredFunctions(StringRef Filename) const
Gets all of the functions in a particular file.
std::error_code make_error_code(coveragemap_error E)
friend bool operator==(const Counter &LHS, const Counter &RHS)
CoverageData getCoverageForExpansion(const ExpansionRecord &Expansion) const
Get the coverage for an expansion within a coverage set.
void pushRegion(CounterMappingRegion Region, uint64_t Count)
A Counter expression is a value that represents an arithmetic operation with two counters.
FunctionRecord(StringRef Name, ArrayRef< StringRef > Filenames)
void log(raw_ostream &OS) const override
Print an error message to an output stream.
friend bool operator!=(const Counter &LHS, const Counter &RHS)
friend bool operator<(const Counter &LHS, const Counter &RHS)
friend bool operator==(const CoverageSegment &L, const CoverageSegment &R)
Iterator over Functions, optionally filtered to a single file.
unsigned Col
The column where this segment begins.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
uint64_t getFuncHash() const
CountedRegion(const CounterMappingRegion &R, uint64_t ExecutionCount)
Tagged union holding either a T or a Error.
const CountedRegion & Region
The region that expands to this record.
StringRef getFuncName(uint64_t FuncNameAddress, size_t NameSize)
Return function's PGO name from the function name's symbol address in the object file.
std::vector< CoverageSegment >::const_iterator begin() const
static Expected< std::unique_ptr< CoverageMapping > > load(ArrayRef< std::unique_ptr< CoverageMappingReader >> CoverageReaders, IndexedInstrProfReader &ProfileReader)
Load the coverage mapping using the given readers.
Coverage information to be processed or displayed.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
CoverageMapError(coveragemap_error Err)
Counter add(Counter LHS, Counter RHS)
Return a counter that represents the expression that adds LHS and RHS.
static CounterMappingRegion makeExpansion(unsigned FileID, unsigned ExpandedFileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
iterator_range< FunctionRecordIterator > getCoveredFunctions() const
Gets all of the functions covered by this profile.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
const std::error_category & coveragemap_category()
unsigned getExpressionID() const
Function Alias Analysis false
The execution count information starting at a point in a file.
static CounterMappingRegion makeRegion(Counter Count, unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
Coverage mapping information for a single function.
uint64_t ExecutionCount
The number of times this function was executed.
unsigned getMismatchedCount()
The number of functions that couldn't have their profiles mapped.
void dump(const Counter &C, raw_ostream &OS) const
CounterKind getKind() const
CoverageData getCoverageForFile(StringRef Filename) const
Get the coverage for a particular file.
A CodeRegion associates some code with a counter.
A Counter mapping context is used to connect the counters, expressions and the obtained counter value...
unsigned getCounterID() const
A Counter mapping region associates a source range with a specific counter.
bool IsRegionEntry
Whether this enters a new region or returns to a previous count.
Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const
static ManagedStatic< _object_error_category > error_category
uint32_t getDataSize() const
CounterMappingRegion(Counter Count, unsigned FileID, unsigned ExpandedFileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd, RegionKind Kind)
Associates a source range with an execution count.
std::pair< unsigned, unsigned > startLoc() const
static coverage::CounterExpression getEmptyKey()
uint64_t getFuncNameRef() const
Counter subtract(Counter LHS, Counter RHS)
Return a counter that represents the expression that subtracts RHS from LHS.
static unsigned getHashValue(const coverage::CounterExpression &V)
CounterExpression(ExprKind Kind, Counter LHS, Counter RHS)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Code coverage information for a single function.
static ErrorSuccess success()
Create a success value.
uint64_t getFuncHash() const
FunctionRecordIterator(ArrayRef< FunctionRecord > Records_, StringRef Filename="")
std::vector< CoverageSegment >::const_iterator end() const
ExpansionRecord(const CountedRegion &Region, const FunctionRecord &Function)
uint64_t Count
The execution count, or zero if no count was recorded.
bool HasCount
When false, the segment was uninstrumented or skipped.
An ExpansionRegion represents a file expansion region that associates a source range with the expansi...
A SkippedRegion represents a source range with code that was skipped by a preprocessor or similar mea...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
A range adaptor for a pair of iterators.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Base class for user error types.
static const unsigned EncodingCounterTagAndExpansionRegionTagBits
Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const
The mapping of profile information to coverage data.
unsigned Line
The line where this segment begins.
CoverageData(StringRef Filename)
std::string message() const override
Return the error message as a string.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
bool isExpression() const
CounterMappingContext(ArrayRef< CounterExpression > Expressions, ArrayRef< uint64_t > CounterValues=None)
std::vector< CountedRegion > CountedRegions
Regions in the function along with their counts.
#define LLVM_PACKED_START
std::string Name
Raw function name.
unsigned FileID
The abstract file this expansion covers.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
IntPtrT getFuncNameRef() const
static const unsigned EncodingTagBits
ArrayRef< CounterExpression > getExpressions() const
FunctionRecord & operator=(FunctionRecord &&)=default
std::vector< std::string > Filenames
Associated files.
Lightweight error class with error context and mandatory checking.
StringSet - A wrapper for StringMap that provides set-like functionality.
std::pair< unsigned, unsigned > endLoc() const
const FunctionRecord & operator*() const
This class implements an extremely fast bulk output stream that can only output to a stream...
void dump(const Counter &C) const
uint32_t getDataSize() const
StringRef - Represent a constant reference to a string, i.e.
Reader for the indexed binary instrprof format.
static Counter getExpression(unsigned ExpressionId)
Return the counter that corresponds to a specific addition counter expression.
A Counter expression builder is used to construct the counter expressions.
std::vector< StringRef > getUniqueSourceFiles() const
Returns a lexicographically sorted, unique list of files that are covered.
ArrayRef< ExpansionRecord > getExpansions() const
Expansions that can be further processed.
A Counter is an abstract value that describes how to compute the execution count for a region of code...
static Counter getCounter(unsigned CounterId)
Return the counter that corresponds to a specific profile counter.
const FunctionRecord & Function
Coverage for the expansion.
Coverage information for a macro expansion or #included file.
FunctionRecordIterator & operator++()