llvm-cov: Added -a option for block data.

Similar to gcov, llvm-cov will now print out the block count at the end
of each block. Multiple blocks can end on the same line.

One computational difference is by using -a, llvm-cov will no longer
simply add the block counts together to form a line count. Instead, it
will take the maximum of the block counts on that line. This has a
similar effect to what gcov does, but generates more correct counts in
certain scenarios.

Also updated tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196856 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Yuchen Wu
2013-12-10 01:02:07 +00:00
parent 06e68434a5
commit 30d5ef51e4
8 changed files with 172 additions and 8 deletions

View File

@@ -34,6 +34,13 @@ namespace GCOV {
};
} // end GCOV namespace
/// GCOVOptions - A struct for passing gcov options between functions.
struct GCOVOptions {
GCOVOptions(bool A): AllBlocks(A) {}
bool AllBlocks;
};
/// GCOVBuffer - A wrapper around MemoryBuffer to provide GCOV specific
/// read operations.
class GCOVBuffer {
@@ -245,6 +252,7 @@ public:
bool readGCNO(GCOVBuffer &Buffer, GCOV::GCOVVersion Version);
bool readGCDA(GCOVBuffer &Buffer, GCOV::GCOVVersion Version);
StringRef getFilename() const { return Filename; }
size_t getNumBlocks() const { return Blocks.size(); }
void dump() const;
void collectLineCounts(FileInfo &FI);
private:
@@ -275,6 +283,7 @@ public:
DstEdges.push_back(Edge);
}
void addLine(uint32_t N) { Lines.push_back(N); }
uint32_t getLastLine() const { return Lines.back(); }
void addCount(size_t DstEdgeNo, uint64_t N);
uint64_t getCount() const { return Counter; }
size_t getNumSrcEdges() const { return SrcEdges.size(); }
@@ -305,7 +314,8 @@ public:
}
void setRunCount(uint32_t Runs) { RunCount = Runs; }
void setProgramCount(uint32_t Programs) { ProgramCount = Programs; }
void print(StringRef GCNOFile, StringRef GCDAFile) const;
void print(StringRef GCNOFile, StringRef GCDAFile,
const GCOVOptions &Options) const;
private:
StringMap<LineData> LineInfo;
uint32_t RunCount;