15 #ifndef LLVM_SUPPORT_GCOV_H
16 #define LLVM_SUPPORT_GCOV_H
72 errs() <<
"Unexpected file type: " << File <<
".\n";
83 errs() <<
"Unexpected file type: " << File <<
".\n";
93 if (VersionStr ==
"*204") {
98 if (VersionStr ==
"*404") {
103 if (VersionStr ==
"*704") {
108 errs() <<
"Unexpected version: " << VersionStr <<
".\n";
116 if (Tag.
empty() || Tag[0] !=
'\0' || Tag[1] !=
'\0' || Tag[2] !=
'\0' ||
128 if (Tag.
empty() || Tag[0] !=
'\0' || Tag[1] !=
'\0' || Tag[2] !=
'\x41' ||
140 if (Tag.
empty() || Tag[0] !=
'\0' || Tag[1] !=
'\0' || Tag[2] !=
'\x43' ||
152 if (Tag.
empty() || Tag[0] !=
'\0' || Tag[1] !=
'\0' || Tag[2] !=
'\x45' ||
164 if (Tag.
empty() || Tag[0] !=
'\0' || Tag[1] !=
'\0' || Tag[2] !=
'\xa1' ||
176 if (Tag.
empty() || Tag[0] !=
'\0' || Tag[1] !=
'\0' || Tag[2] !=
'\0' ||
188 if (Tag.
empty() || Tag[0] !=
'\0' || Tag[1] !=
'\0' || Tag[2] !=
'\0' ||
198 errs() <<
"Unexpected end of memory buffer: " << Cursor + 4 <<
".\n";
211 Val = ((uint64_t)Hi << 32) |
Lo;
224 errs() <<
"Unexpected end of memory buffer: " << Cursor + Len <<
".\n";
245 : GCNOInitialized(
false), Checksum(0), RunCount(0),
255 bool GCNOInitialized;
310 EdgeWeight(
GCOVBlock *
D) : Dst(D), Count(0) {}
316 struct SortDstEdgesFunctor {
318 return E1->
Dst.Number < E2->
Dst.Number;
326 : Parent(P), Number(N), Counter(0), DstEdgesAreSorted(
true) {}
332 void addCount(
size_t DstEdgeNo, uint64_t
N);
337 SrcEdges.push_back(Edge);
343 if (DstEdges.size() && DstEdges.back()->Dst.Number > Edge->
Dst.Number)
344 DstEdgesAreSorted =
false;
345 DstEdges.push_back(Edge);
371 bool DstEdgesAreSorted;
389 LineData() : LastLine(0) {}
395 struct GCOVCoverage {
397 :
Name(Name), LogicalLines(0), LinesExec(0), Branches(0),
398 BranchesExec(0), BranchesTaken(0) {}
412 : Options(Options), RunCount(0), ProgramCount(0) {}
415 if (Line > LineInfo[Filename].LastLine)
416 LineInfo[Filename].LastLine = Line;
417 LineInfo[Filename].Blocks[Line - 1].push_back(Block);
422 if (Line > LineInfo[Filename].LastLine)
423 LineInfo[Filename].LastLine = Line;
424 LineInfo[Filename].Functions[Line - 1].push_back(Function);
434 std::unique_ptr<raw_ostream> openCoveragePath(
StringRef CoveragePath);
435 void printFunctionSummary(
raw_ostream &OS,
const FunctionVector &Funcs)
const;
439 GCOVCoverage &Coverage,
uint32_t &EdgeNo);
441 uint64_t Count)
const;
443 void printCoverage(
raw_ostream &OS,
const GCOVCoverage &Coverage)
const;
455 FileCoverageList FileCoverages;
456 FuncCoverageMap FuncCoverages;
461 #endif // LLVM_SUPPORT_GCOV_H
void push_back(const T &Elt)
iterator_range< EdgeIterator > dsts() const
GCOVBlock(GCOVFunction &P, uint32_t N)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
bool readGCNO(GCOVBuffer &Buffer, GCOV::GCOVVersion Version)
readGCNO - Read a function from the GCNO buffer.
EdgeIterator dst_begin() const
bool readInt(uint32_t &Val)
bool readGCDAFormat()
readGCDAFormat - Check GCDA signature is valid at the beginning of buffer.
GCOVEdge - Collects edge information.
void addFunctionLine(StringRef Filename, uint32_t Line, const GCOVFunction *Function)
void print(raw_ostream &OS, StringRef MainFilename, StringRef GCNOFile, StringRef GCDAFile)
print - Print source files with collected line count information.
uint64_t getCount() const
bool readLineTag()
readLineTag - If cursor points to a line tag then increment the cursor and return true otherwise retu...
void setProgramCount(uint32_t Programs)
SmallVectorImpl< GCOVEdge * >::const_iterator EdgeIterator
BlockIterator block_begin() const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
bool readString(StringRef &Str)
size_t getNumBlocks() const
uint32_t getChecksum() const
A struct for passing gcov options between functions.
StringRef getBuffer() const
void dump() const
dump - Dump GCOVFile content to dbgs() for debugging purposes.
void addBlockLine(StringRef Filename, uint32_t Line, const GCOVBlock *Block)
GCOVBuffer - A wrapper around MemoryBuffer to provide GCOV specific read operations.
uint32_t getLastLine() const
iterator_range< BlockIterator > blocks() const
StringRef getName() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
EdgeIterator dst_end() const
void collectLineCounts(FileInfo &FI)
collectLineCounts - Collect line counts.
bool readGCDA(GCOVBuffer &Buffer)
readGCDA - Read GCDA buffer.
bool readArcTag()
readArcTag - If cursor points to an gcda arc tag then increment the cursor and return true otherwise ...
void addDstEdge(GCOVEdge *Edge)
void dump() const
dump - Dump GCOVBlock content to dbgs() for debugging purposes.
Function Alias Analysis false
GCOVBlock - Collects block information.
uint64_t getExitCount() const
getExitCount - Get the number of times the function returned by retrieving the exit block's count...
GCOVFunction(GCOVFile &P)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
iterator_range< EdgeIterator > srcs() const
pointee_iterator< SmallVectorImpl< std::unique_ptr< GCOVBlock > >::const_iterator > BlockIterator
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
void sortDstEdges()
sortDstEdges - Sort destination edges by block number, nop if already sorted.
bool readInt64(uint64_t &Val)
void collectLineCounts(FileInfo &FI)
collectLineCounts - Collect line counts.
EdgeIterator src_begin() const
void addSrcEdge(GCOVEdge *Edge)
bool readBlockTag()
readBlockTag - If cursor points to a block tag then increment the cursor and return true otherwise re...
BlockIterator block_end() const
void dump() const
dump - Dump GCOVFunction content to dbgs() for debugging purposes.
bool readGCNOFormat()
readGCNOFormat - Check GCNO signature is valid at the beginning of buffer.
void advanceCursor(uint32_t n)
bool readGCNO(GCOVBuffer &Buffer)
readGCNO - Read GCNO buffer.
const GCOVFunction & getParent() const
Options(bool A, bool B, bool C, bool F, bool P, bool U, bool L, bool N)
bool readEdgeTag()
readEdgeTag - If cursor points to an edge tag then increment the cursor and return true otherwise ret...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
GCOVBuffer(MemoryBuffer *B)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
GCOVEdge(GCOVBlock &S, GCOVBlock &D)
An iterator type that allows iterating over the pointees via some other iterator. ...
bool readGCDA(GCOVBuffer &Buffer, GCOV::GCOVVersion Version)
readGCDA - Read a function from the GCDA buffer.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
This interface provides simple read-only access to a block of memory, and provides simple methods for...
EdgeIterator src_end() const
A range adaptor for a pair of iterators.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
size_t getNumSrcEdges() const
StringRef getFilename() const
FileInfo(const GCOV::Options &Options)
void collectLineCounts(FileInfo &FI)
collectLineCounts - Collect line counts.
GCOVFunction - Collects function information.
size_t getNumDstEdges() const
bool readObjectTag()
readObjectTag - If cursor points to an object summary tag then increment the cursor and return true o...
GCOVFile - Collects coverage information for one pair of coverage file (.gcno and ...
uint64_t getEntryCount() const
getEntryCount - Get the number of times the function was called by retrieving the entry block's count...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint64_t getCursor() const
~GCOVBlock()
~GCOVBlock - Delete GCOVBlock and its content.
This class implements an extremely fast bulk output stream that can only output to a stream...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
bool readProgramTag()
readProgramTag - If cursor points to a program summary tag then increment the cursor and return true ...
StringRef - Represent a constant reference to a string, i.e.
bool readFunctionTag()
readFunctionTag - If cursor points to a function tag then increment the cursor and return true otherw...
void addCount(size_t DstEdgeNo, uint64_t N)
addCount - Add to block counter while storing the edge count.
void setRunCount(uint32_t Runs)
bool readGCOVVersion(GCOV::GCOVVersion &Version)
readGCOVVersion - Read GCOV version.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")