diff options
author | Yuchen Wu <yuchenericwu@hotmail.com> | 2013-12-16 22:14:02 +0000 |
---|---|---|
committer | Yuchen Wu <yuchenericwu@hotmail.com> | 2013-12-16 22:14:02 +0000 |
commit | 89452cf827d9699027b60212b2795b9e14d5ea7a (patch) | |
tree | ce6adccda064c510b0aff95edbb87d20d0bcd458 /lib/IR | |
parent | e77491226adefca4fe5aebb1e689c9d04903cc90 (diff) | |
download | llvm-89452cf827d9699027b60212b2795b9e14d5ea7a.tar.gz llvm-89452cf827d9699027b60212b2795b9e14d5ea7a.tar.bz2 llvm-89452cf827d9699027b60212b2795b9e14d5ea7a.tar.xz |
llvm-cov: Added -u option for unconditional branch info.
Outputs branch information for unconditional branches in addition to
conditional branches. -b option must be enabled.
Also updated tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197432 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r-- | lib/IR/GCOV.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp index 78ff262516..929a5d45ca 100644 --- a/lib/IR/GCOV.cpp +++ b/lib/IR/GCOV.cpp @@ -481,8 +481,13 @@ void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile) const { continue; if (Options.AllBlocks) printBlockInfo(OS, *Block, LineIndex, BlockNo); - if (Options.BranchProb) - printBranchInfo(OS, *Block, LineIndex, EdgeNo); + if (Options.BranchProb) { + size_t NumEdges = Block->getNumDstEdges(); + if (NumEdges > 1) + printBranchInfo(OS, *Block, EdgeNo); + else if (Options.UncondBranch && NumEdges == 1) + printUncondBranchInfo(OS, EdgeNo, (*Block->dst_begin())->Count); + } } } } @@ -521,13 +526,9 @@ void FileInfo::printBlockInfo(raw_fd_ostream &OS, const GCOVBlock &Block, OS << format("%5u-block %2u\n", LineIndex+1, BlockNo++); } -/// printBranchInfo - Print branch probabilities for blocks that have -/// conditional branches. +/// printBranchInfo - Print conditional branch probabilities. void FileInfo::printBranchInfo(raw_fd_ostream &OS, const GCOVBlock &Block, - uint32_t LineIndex, uint32_t &EdgeNo) const { - if (Block.getNumDstEdges() < 2) - return; - + uint32_t &EdgeNo) const { SmallVector<uint64_t, 16> BranchCounts; uint64_t TotalCounts = 0; for (GCOVBlock::EdgeIterator I = Block.dst_begin(), E = Block.dst_end(); @@ -546,3 +547,12 @@ void FileInfo::printBranchInfo(raw_fd_ostream &OS, const GCOVBlock &Block, OS << format("branch %2u never executed\n", EdgeNo++); } } + +/// printUncondBranchInfo - Print unconditional branch probabilities. +void FileInfo::printUncondBranchInfo(raw_fd_ostream &OS, uint32_t &EdgeNo, + uint64_t Count) const { + if (Count) + OS << format("unconditional %2u taken 100%%\n", EdgeNo++); + else + OS << format("unconditional %2u never executed\n", EdgeNo++); +} |