[llvm] r313220 - Add optional profile counts to block frequency dump.
Hiroshi Yamauchi via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 17:20:25 PDT 2017
Author: yamauchi
Date: Wed Sep 13 17:20:25 2017
New Revision: 313220
URL: http://llvm.org/viewvc/llvm-project?rev=313220&view=rev
Log:
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
Modified:
llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h
llvm/trunk/include/llvm/IR/Function.h
Modified: llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h?rev=313220&r1=313219&r2=313220&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h Wed Sep 13 17:20:25 2017
@@ -1280,7 +1280,12 @@ raw_ostream &BlockFrequencyInfoImpl<BT>:
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.
Modified: llvm/trunk/include/llvm/IR/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Function.h?rev=313220&r1=313219&r2=313220&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Function.h (original)
+++ llvm/trunk/include/llvm/IR/Function.h Wed Sep 13 17:20:25 2017
@@ -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);
More information about the llvm-commits
mailing list