[PATCH] D37835: Add optional profile counts to block frequency dump.
Hiroshi Yamauchi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 16:30:46 PDT 2017
yamauchi created this revision.
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.
https://reviews.llvm.org/D37835
Files:
include/llvm/Analysis/BlockFrequencyInfoImpl.h
include/llvm/IR/Function.h
Index: include/llvm/IR/Function.h
===================================================================
--- include/llvm/IR/Function.h
+++ include/llvm/IR/Function.h
@@ -128,6 +128,11 @@
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);
Index: include/llvm/Analysis/BlockFrequencyInfoImpl.h
===================================================================
--- include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -1280,7 +1280,12 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37835.115136.patch
Type: text/x-patch
Size: 1461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170913/7e56da2a/attachment.bin>
More information about the llvm-commits
mailing list