diff options
author | Yuchen Wu <yuchenericwu@hotmail.com> | 2013-10-25 02:22:21 +0000 |
---|---|---|
committer | Yuchen Wu <yuchenericwu@hotmail.com> | 2013-10-25 02:22:21 +0000 |
commit | 76fa4d629b22903632529e2cb19c86105a0d1247 (patch) | |
tree | 02524980ed7dde2b279b58f870e1a3d22d934863 /include/llvm/Support/GCOV.h | |
parent | e034422d2a833ea1e257efe88696b6e93743b042 (diff) | |
download | llvm-76fa4d629b22903632529e2cb19c86105a0d1247.tar.gz llvm-76fa4d629b22903632529e2cb19c86105a0d1247.tar.bz2 llvm-76fa4d629b22903632529e2cb19c86105a0d1247.tar.xz |
Support for reading program counts in llvm-cov.
llvm-cov will now be able to read program counts from the GCDA file and
output it in the same format as gcov. The program summary tag was
identified from gcov-io.h as "\0\0\0\a3".
There is currently a bug in GCOVProfiling.cpp which does not generate
the
run- or program-counting IR, so this change was tested manually by
modifying the GCDA file and comparing the gcov and llvm-cov outputs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193389 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/GCOV.h')
-rw-r--r-- | include/llvm/Support/GCOV.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index 4bcd0ed0c3..ef1a4ebd71 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -126,6 +126,19 @@ public: return true; } + /// readProgramTag - If cursor points to a program summary tag then increment + /// the cursor and return true otherwise return false. + bool readProgramTag() { + StringRef Tag = Buffer->getBuffer().slice(Cursor, Cursor+4); + if (Tag.empty() || + Tag[0] != '\0' || Tag[1] != '\0' || + Tag[2] != '\0' || Tag[3] != '\xa3') { + return false; + } + Cursor += 4; + return true; + } + uint32_t readInt() { uint32_t Result; StringRef Str = Buffer->getBuffer().slice(Cursor, Cursor+4); @@ -159,13 +172,14 @@ private: /// (.gcno and .gcda). class GCOVFile { public: - GCOVFile() {} + GCOVFile() : Functions(), ProgramCount(0) {} ~GCOVFile(); bool read(GCOVBuffer &Buffer); void dump(); void collectLineCounts(FileInfo &FI); private: SmallVector<GCOVFunction *, 16> Functions; + uint32_t ProgramCount; }; /// GCOVFunction - Collects function information. @@ -220,9 +234,11 @@ public: void addLineCount(StringRef Filename, uint32_t Line, uint64_t Count) { LineInfo[Filename][Line-1] += Count; } + void setProgramCount(uint32_t PC) { ProgramCount = PC; } void print(StringRef gcnoFile, StringRef gcdaFile); private: StringMap<LineCounts> LineInfo; + uint32_t ProgramCount; }; } |