summaryrefslogtreecommitdiff
path: root/include/llvm/Support/GCOV.h
diff options
context:
space:
mode:
authorYuchen Wu <yuchenericwu@hotmail.com>2013-10-24 01:51:04 +0000
committerYuchen Wu <yuchenericwu@hotmail.com>2013-10-24 01:51:04 +0000
commitcbbd20879e8acf35d3326a2459e17a298b5f5d15 (patch)
tree81fd09c165f8dfa30e0eb61c2dec5fec08328bfc /include/llvm/Support/GCOV.h
parent577ac566c45670cd8ef03e202cb92258c643574d (diff)
downloadllvm-cbbd20879e8acf35d3326a2459e17a298b5f5d15.tar.gz
llvm-cbbd20879e8acf35d3326a2459e17a298b5f5d15.tar.bz2
llvm-cbbd20879e8acf35d3326a2459e17a298b5f5d15.tar.xz
Fixed llvm-cov to count edges instead of blocks.
This was a fundamental flaw in llvm-cov where it treated the values in the GCDA files as block counts instead of edge counts. This created incorrect line counts when branching was present. Instead, the edge counts should be summed to obtain the correct block count. The fix was tested using custom test files as well as single source files from the test-suite directory. The behaviour can be verified by reading the GCOV documentation that describes the GCDA spec ("ARC_COUNTS gives the counter values for those arcs that are instrumented") and the header description provided by GCOVProfiling.cpp ("instruments the code that runs to records (sic) the edges between blocks that run and emit a complementary "gcda" file on exit"). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193299 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/GCOV.h')
-rw-r--r--include/llvm/Support/GCOV.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h
index f1e7998bc4..4bcd0ed0c3 100644
--- a/include/llvm/Support/GCOV.h
+++ b/include/llvm/Support/GCOV.h
@@ -191,7 +191,8 @@ public:
~GCOVBlock();
void addEdge(uint32_t N) { Edges.push_back(N); }
void addLine(StringRef Filename, uint32_t LineNo);
- void addCount(uint64_t N) { Counter = N; }
+ void addCount(uint64_t N) { Counter += N; }
+ size_t getNumEdges() { return Edges.size(); }
void dump();
void collectLineCounts(FileInfo &FI);
private:
@@ -217,7 +218,7 @@ typedef DenseMap<uint32_t, uint64_t> LineCounts;
class FileInfo {
public:
void addLineCount(StringRef Filename, uint32_t Line, uint64_t Count) {
- LineInfo[Filename][Line-1] = Count;
+ LineInfo[Filename][Line-1] += Count;
}
void print(StringRef gcnoFile, StringRef gcdaFile);
private: