diff options
author | Yuchen Wu <yuchenericwu@hotmail.com> | 2013-12-10 01:02:07 +0000 |
---|---|---|
committer | Yuchen Wu <yuchenericwu@hotmail.com> | 2013-12-10 01:02:07 +0000 |
commit | 30d5ef51e4e20d5114bd80b1ef036d91e4410ae2 (patch) | |
tree | be4749d275aac25267c25edb0161295011197565 /lib/IR/GCOV.cpp | |
parent | 06e68434a5fdc33de8a4b704f63c89a45eb2d699 (diff) | |
download | llvm-30d5ef51e4e20d5114bd80b1ef036d91e4410ae2.tar.gz llvm-30d5ef51e4e20d5114bd80b1ef036d91e4410ae2.tar.bz2 llvm-30d5ef51e4e20d5114bd80b1ef036d91e4410ae2.tar.xz |
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
Diffstat (limited to 'lib/IR/GCOV.cpp')
-rw-r--r-- | lib/IR/GCOV.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp index c7a1102d10..fb7370020a 100644 --- a/lib/IR/GCOV.cpp +++ b/lib/IR/GCOV.cpp @@ -358,7 +358,8 @@ void GCOVBlock::dump() const { // FileInfo implementation. /// print - Print source files with collected line count information. -void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile) const { +void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile, + const GCOVOptions &Options) const { for (StringMap<LineData>::const_iterator I = LineInfo.begin(), E = LineInfo.end(); I != E; ++I) { StringRef Filename = I->first(); @@ -385,13 +386,21 @@ void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile) const { for (uint32_t i = 0; !AllLines.empty(); ++i) { LineData::const_iterator BlocksIt = Line.find(i); - // Add up the block counts to form line counts. if (BlocksIt != Line.end()) { + // Add up the block counts to form line counts. const BlockVector &Blocks = BlocksIt->second; uint64_t LineCount = 0; for (BlockVector::const_iterator I = Blocks.begin(), E = Blocks.end(); I != E; ++I) { - LineCount += (*I)->getCount(); + const GCOVBlock *Block = *I; + if (Options.AllBlocks) { + // Only take the highest block count for that line. + uint64_t BlockCount = Block->getCount(); + LineCount = LineCount > BlockCount ? LineCount : BlockCount; + } else { + // Sum up all of the block counts. + LineCount += Block->getCount(); + } } if (LineCount == 0) OS << " #####:"; @@ -403,6 +412,24 @@ void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile) const { std::pair<StringRef, StringRef> P = AllLines.split('\n'); OS << format("%5u:", i+1) << P.first << "\n"; AllLines = P.second; + + if (Options.AllBlocks && BlocksIt != Line.end()) { + // Output the counts for each block at the last line of the block. + uint32_t BlockNo = 0; + const BlockVector &Blocks = BlocksIt->second; + for (BlockVector::const_iterator I = Blocks.begin(), E = Blocks.end(); + I != E; ++I) { + const GCOVBlock *Block = *I; + if (Block->getLastLine() != i+1) + continue; + + if (Block->getCount() == 0) + OS << " $$$$$:"; + else + OS << format("%9lu:", Block->getCount()); + OS << format("%5u-block %u\n", i+1, BlockNo++); + } + } } } } |