diff options
author | Hiroshi Yamauchi <yamauchi@google.com> | 2017-09-14 00:20:25 +0000 |
---|---|---|
committer | Hiroshi Yamauchi <yamauchi@google.com> | 2017-09-14 00:20:25 +0000 |
commit | 5622381add2948e3baa2822ac02d4184b904f494 (patch) | |
tree | 52bb0ffcac51107565b1bd92ea13e1547cf7e0d5 | |
parent | 09f613df6963c4cc48671950df7d7abce9745bdf (diff) | |
download | bcm5719-llvm-5622381add2948e3baa2822ac02d4184b904f494.tar.gz bcm5719-llvm-5622381add2948e3baa2822ac02d4184b904f494.zip |
Add optional profile counts to block frequency dump.
Summary:
Print profile counts as the third value in addition to the existing 'float' and
the 'int' values in the textual block frequency dump, if available.
Reviewers: davidxl
Reviewed By: davidxl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D37835
llvm-svn: 313220
-rw-r--r-- | llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h | 7 | ||||
-rw-r--r-- | llvm/include/llvm/IR/Function.h | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h index a5f3e82876f..7f166f4a646 100644 --- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -1280,7 +1280,12 @@ raw_ostream &BlockFrequencyInfoImpl<BT>::print(raw_ostream &OS) const { for (const BlockT &BB : *F) { OS << " - " << bfi_detail::getBlockName(&BB) << ": float = "; getFloatingBlockFreq(&BB).print(OS, 5) - << ", int = " << getBlockFreq(&BB).getFrequency() << "\n"; + << ", int = " << getBlockFreq(&BB).getFrequency(); + if (Optional<uint64_t> ProfileCount = + BlockFrequencyInfoImplBase::getBlockProfileCount( + *F->getFunction(), getNode(&BB))) + OS << ", count = " << ProfileCount.getValue(); + OS << "\n"; } // Add an extra newline for readability. diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h index 600c95f208d..574a40e90f8 100644 --- a/llvm/include/llvm/IR/Function.h +++ b/llvm/include/llvm/IR/Function.h @@ -128,6 +128,11 @@ public: void operator=(const Function&) = delete; ~Function(); + // This is here to help easily convert from FunctionT * (Function * or + // MachineFunction *) in BlockFrequencyInfoImpl to Function * by calling + // FunctionT->getFunction(). + const Function *getFunction() const { return this; } + static Function *Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N = "", Module *M = nullptr) { return new Function(Ty, Linkage, N, M); |