15 #ifndef LLVM_PROFILEDATA_COVERAGEMAPPING_H_
16 #define LLVM_PROFILEDATA_COVERAGEMAPPING_H_
26 #include <system_error>
30 class IndexedInstrProfReader;
36 struct CounterExpressions;
69 return LHS.Kind == RHS.Kind && LHS.ID == RHS.ID;
77 return std::tie(LHS.Kind, LHS.ID) < std::tie(RHS.Kind, RHS.ID);
103 : Kind(Kind), LHS(LHS), RHS(RHS) {}
111 std::vector<CounterExpression> Expressions;
127 void extractTerms(
Counter C,
int Sign,
171 : Count(Count), FileID(FileID), ExpandedFileID(ExpandedFileID),
172 LineStart(LineStart), ColumnStart(ColumnStart), LineEnd(LineEnd),
173 ColumnEnd(ColumnEnd), Kind(Kind) {}
186 ColumnStart, LineEnd, ColumnEnd,
198 inline std::pair<unsigned, unsigned>
startLoc()
const {
202 inline std::pair<unsigned, unsigned>
endLoc()
const {
240 : Expressions(Expressions), CounterValues(CounterValues) {}
264 : Name(Name), Filenames(Filenames.
begin(), Filenames.
end()) {}
276 std::forward_iterator_tag, FunctionRecord> {
282 void skipOtherFiles();
287 : Records(Records_), Current(Records.
begin()), Filename(Filename) {
294 return Current == RHS.Current && Filename == RHS.Filename;
300 assert(Current != Records.end() &&
"incremented past end");
322 :
FileID(Region.ExpandedFileID), Region(Region), Function(Function) {}
343 IsRegionEntry(IsRegionEntry) {}
348 IsRegionEntry(IsRegionEntry) {}
369 std::string Filename;
370 std::vector<CoverageSegment> Segments;
371 std::vector<ExpansionRecord> Expansions;
380 : Filename(std::move(RHS.Filename)), Segments(std::move(RHS.Segments)),
381 Expansions(std::move(RHS.Expansions)) {}
386 std::vector<CoverageSegment>::iterator
begin() {
return Segments.begin(); }
387 std::vector<CoverageSegment>::iterator
end() {
return Segments.end(); }
388 bool empty() {
return Segments.empty(); }
399 std::vector<FunctionRecord> Functions;
400 unsigned MismatchedFunctionCount;
462 using namespace coverage;
463 return CounterExpression(CounterExpression::ExprKind::Subtract,
464 Counter::getCounter(~0U),
465 Counter::getCounter(~0U));
469 using namespace coverage;
470 return CounterExpression(CounterExpression::ExprKind::Add,
471 Counter::getCounter(~0U),
472 Counter::getCounter(~0U));
476 return static_cast<unsigned>(
509 #endif // LLVM_PROFILEDATA_COVERAGEMAPPING_H_
const_iterator end(StringRef path)
Get end iterator over path.
static coverage::CounterExpression getTombstoneKey()
Represents either an error or a value T.
bool operator==(const FunctionRecordIterator &RHS) const
static const unsigned EncodingTagMask
const std::error_category & coveragemap_category()
static Counter getZero()
Return the counter that represents the number zero.
CoverageSegment(unsigned Line, unsigned Col, uint64_t Count, bool IsRegionEntry)
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)
static bool isEqual(const coverage::CounterExpression &LHS, const coverage::CounterExpression &RHS)
std::vector< const FunctionRecord * > getInstantiations(StringRef Filename)
Get the list of function instantiations in the file.
iterator_range< FunctionRecordIterator > getCoveredFunctions(StringRef Filename) const
Gets all of the functions in a particular file.
StringRef getFilename()
Get the name of the file this data covers.
const_iterator begin(StringRef path)
Get begin iterator over path.
friend bool operator==(const Counter &LHS, const Counter &RHS)
static ErrorOr< std::unique_ptr< CoverageMapping > > load(CoverageMappingReader &CoverageReader, IndexedInstrProfReader &ProfileReader)
Load the coverage mapping using the given readers.
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)
CoverageData getCoverageForExpansion(const ExpansionRecord &Expansion)
Get the coverage for an expansion within a coverage set.
ErrorOr< int64_t > evaluate(const Counter &C) const
Return the number of times that a region of code associated with this counter was executed...
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.
bool contains(const CounterMappingRegion &Other) const
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...
CountedRegion(const CounterMappingRegion &R, uint64_t ExecutionCount)
std::error_code make_error_code(BitcodeError E)
const CountedRegion & Region
The region that expands to this record.
Coverage information to be processed or displayed.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
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 ...
unsigned getExpressionID() const
The execution count information starting at a point in a file.
std::vector< ExpansionRecord > getExpansions()
Expansions that can be further processed.
static CounterMappingRegion makeRegion(Counter Count, unsigned FileID, unsigned LineStart, unsigned ColumnStart, unsigned LineEnd, unsigned ColumnEnd)
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, llvm::raw_ostream &OS) const
CounterKind getKind() const
std::vector< CoverageSegment >::iterator end()
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.
static ManagedStatic< _object_error_category > error_category
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()
CounterMappingContext(ArrayRef< CounterExpression > Expressions, ArrayRef< uint64_t > CounterValues=ArrayRef< uint64_t >())
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.
CoverageData getCoverageForFile(StringRef Filename)
Get the coverage for a particular file.
Code coverage information for a single function.
FunctionRecordIterator(ArrayRef< FunctionRecord > Records_, StringRef Filename="")
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.
void setCount(uint64_t NewCount)
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...
CoverageData(CoverageData &&RHS)
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.
bool operator<(const CounterMappingRegion &Other) const
static const unsigned EncodingCounterTagAndExpansionRegionTagBits
std::vector< CoverageSegment >::iterator begin()
The mapping of profile information to coverage data.
unsigned Line
The line where this segment begins.
CoverageData(StringRef Filename)
CoverageData getCoverageForFunction(const FunctionRecord &Function)
Get the coverage for a particular function.
bool isExpression() const
std::vector< CountedRegion > CountedRegions
Regions in the function along with their counts.
std::string Name
Raw function name.
Provides ErrorOr<T> smart pointer.
unsigned FileID
The abstract file this expansion covers.
static const unsigned EncodingTagBits
ArrayRef< CounterExpression > getExpressions() const
std::vector< std::string > Filenames
Associated files.
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
StringRef - Represent a constant reference to a string, i.e.
void addCount(uint64_t NewCount)
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 the list of files that are covered.
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++()