summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h7
-rw-r--r--llvm/include/llvm/IR/Function.h5
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);
OpenPOWER on IntegriCloud