diff options
author | Yuchen Wu <yuchenericwu@hotmail.com> | 2013-12-03 00:24:44 +0000 |
---|---|---|
committer | Yuchen Wu <yuchenericwu@hotmail.com> | 2013-12-03 00:24:44 +0000 |
commit | 2331c9f887346d522826175f446129d2b055d084 (patch) | |
tree | c399ff48f24d29a47efe5f62b2f65df46ee516ea /include | |
parent | c4b184e229aaa35c2c7b1463a22d6fd4c9f81aec (diff) | |
download | llvm-2331c9f887346d522826175f446129d2b055d084.tar.gz llvm-2331c9f887346d522826175f446129d2b055d084.tar.bz2 llvm-2331c9f887346d522826175f446129d2b055d084.tar.xz |
llvm-cov: Added edge struct for traversal in block.
Added GCOVEdge which are simple structs owned by the GCOVFunction that
stores the source and destination GCOVBlocks, as well as the counts.
Changed GCOVBlocks so that it stores a vector of source GCOVEdges and a
vector of destination GCOVEdges, rather than just the block number.
Storing the block number was only useful for knowing the number of edges
and for debug info. Using a struct is useful for traversing the edges,
especially back edges which may be needed later.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196175 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Support/GCOV.h | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index 9649a1dad3..ee81229ff8 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -205,6 +205,14 @@ private: uint32_t ProgramCount; }; +struct GCOVEdge { + GCOVEdge(GCOVBlock *S, GCOVBlock *D): Src(S), Dst(D), Count(0) {} + + GCOVBlock *Src; + GCOVBlock *Dst; + uint64_t Count; +}; + /// GCOVFunction - Collects function information. class GCOVFunction { public: @@ -221,25 +229,43 @@ private: StringRef Name; StringRef Filename; SmallVector<GCOVBlock *, 16> Blocks; + SmallVector<GCOVEdge *, 16> Edges; }; /// GCOVBlock - Collects block information. class GCOVBlock { public: + typedef SmallVectorImpl<GCOVEdge *>::const_iterator EdgeIterator; + GCOVBlock(GCOVFunction &P, uint32_t N) : - Parent(P), Number(N), Counter(0), Edges(), Lines() {} + Parent(P), Number(N), Counter(0), SrcEdges(), DstEdges(), Lines() {} ~GCOVBlock(); - void addEdge(uint32_t N) { Edges.push_back(N); } + void addSrcEdge(GCOVEdge *Edge) { + assert(Edge->Dst == this); // up to caller to ensure edge is valid + SrcEdges.push_back(Edge); + } + void addDstEdge(GCOVEdge *Edge) { + assert(Edge->Src == this); // up to caller to ensure edge is valid + DstEdges.push_back(Edge); + } void addLine(uint32_t N) { Lines.push_back(N); } - void addCount(uint64_t N) { Counter += N; } - size_t getNumEdges() const { return Edges.size(); } + void addCount(size_t DstEdgeNo, uint64_t N); + size_t getNumSrcEdges() const { return SrcEdges.size(); } + size_t getNumDstEdges() const { return DstEdges.size(); } + + EdgeIterator src_begin() const { return SrcEdges.begin(); } + EdgeIterator src_end() const { return SrcEdges.end(); } + EdgeIterator dst_begin() const { return DstEdges.begin(); } + EdgeIterator dst_end() const { return DstEdges.end(); } + void dump() const; void collectLineCounts(FileInfo &FI); private: GCOVFunction &Parent; uint32_t Number; uint64_t Counter; - SmallVector<uint32_t, 16> Edges; + SmallVector<GCOVEdge *, 16> SrcEdges; + SmallVector<GCOVEdge *, 16> DstEdges; SmallVector<uint32_t, 16> Lines; }; |