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
This commit is contained in:
Hiroshi Yamauchi 2017-09-14 00:20:25 +00:00
parent 09f613df69
commit 5622381add
2 changed files with 11 additions and 1 deletions

View File

@ -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.

View File

@ -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);