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 | 66d93b82ac7fe2c7cc82ffb61a1ad07a7838397f (patch) | |
tree | b2a71c66287c3f805b80ecb3f890c627911c1331 /llvm/lib/IR/GCOV.cpp | |
parent | 9ed985baadc3b1df704892d1c85a97c38a19e46a (diff) | |
download | bcm5719-llvm-66d93b82ac7fe2c7cc82ffb61a1ad07a7838397f.tar.gz bcm5719-llvm-66d93b82ac7fe2c7cc82ffb61a1ad07a7838397f.zip |
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.
llvm-svn: 197432
Diffstat (limited to 'llvm/lib/IR/GCOV.cpp')
-rw-r--r-- | llvm/lib/IR/GCOV.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/llvm/lib/IR/GCOV.cpp b/llvm/lib/IR/GCOV.cpp index 78ff2625160..929a5d45ca6 100644 --- a/llvm/lib/IR/GCOV.cpp +++ b/llvm/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++); +} |