summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Support/GCOV.h5
-rw-r--r--llvm/lib/IR/GCOV.cpp13
2 files changed, 14 insertions, 4 deletions
diff --git a/llvm/include/llvm/Support/GCOV.h b/llvm/include/llvm/Support/GCOV.h
index f1e7998bc4b..4bcd0ed0c39 100644
--- a/llvm/include/llvm/Support/GCOV.h
+++ b/llvm/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:
diff --git a/llvm/lib/IR/GCOV.cpp b/llvm/lib/IR/GCOV.cpp
index 68b91e6dc9a..908523a3a66 100644
--- a/llvm/lib/IR/GCOV.cpp
+++ b/llvm/lib/IR/GCOV.cpp
@@ -103,9 +103,18 @@ bool GCOVFunction::read(GCOVBuffer &Buff, GCOV::GCOVFormat Format) {
if (Format == GCOV::GCDA_402 || Format == GCOV::GCDA_404) {
Buff.readArcTag();
+ uint32_t i = 0;
uint32_t Count = Buff.readInt() / 2;
- for (unsigned i = 0, e = Count; i != e; ++i) {
- Blocks[i]->addCount(Buff.readInt64());
+
+ // This for loop adds the counts for each block. A second nested loop is
+ // required to combine the edge counts that are contained in the GCDA file.
+ for (uint32_t Line = 0; i < Count; ++Line) {
+ GCOVBlock &Block = *Blocks[Line];
+ for (size_t Edge = 0, End = Block.getNumEdges(); Edge < End; ++Edge) {
+ assert(i < Count && "Unexpected number of Edges!");
+ Block.addCount(Buff.readInt64());
+ ++i;
+ }
}
return true;
}
OpenPOWER on IntegriCloud