diff options
| author | Xinliang David Li <davidxl@google.com> | 2016-06-22 17:12:12 +0000 |
|---|---|---|
| committer | Xinliang David Li <davidxl@google.com> | 2016-06-22 17:12:12 +0000 |
| commit | b12b353a4103f88ce635a609b3513b5a3b7f6e70 (patch) | |
| tree | 8c7500b558599ca1844c8e1ac40188308cc2bbc0 /llvm/lib | |
| parent | 9d5057cce535bf3b6e80b294325beb4ffbc18980 (diff) | |
| download | bcm5719-llvm-b12b353a4103f88ce635a609b3513b5a3b7f6e70.tar.gz bcm5719-llvm-b12b353a4103f88ce635a609b3513b5a3b7f6e70.zip | |
[BFI]: NFC refactoring
move getBlockProfileCount implementation to the
base class so that MBFI can share too.
llvm-svn: 273442
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/BlockFrequencyInfo.cpp | 15 | ||||
| -rw-r--r-- | llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp | 16 |
2 files changed, 20 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/BlockFrequencyInfo.cpp b/llvm/lib/Analysis/BlockFrequencyInfo.cpp index a0c472d7c72..ac7f6e28b3d 100644 --- a/llvm/lib/Analysis/BlockFrequencyInfo.cpp +++ b/llvm/lib/Analysis/BlockFrequencyInfo.cpp @@ -140,20 +140,13 @@ BlockFrequency BlockFrequencyInfo::getBlockFreq(const BasicBlock *BB) const { Optional<uint64_t> BlockFrequencyInfo::getBlockProfileCount(const BasicBlock *BB) const { - auto EntryCount = getFunction()->getEntryCount(); - if (!EntryCount) + if (!BFI) return None; - // Use 128 bit APInt to do the arithmetic to avoid overflow. - APInt BlockCount(128, EntryCount.getValue()); - APInt BlockFreq(128, getBlockFreq(BB).getFrequency()); - APInt EntryFreq(128, getEntryFreq()); - BlockCount *= BlockFreq; - BlockCount = BlockCount.udiv(EntryFreq); - return BlockCount.getLimitedValue(); + + return BFI->getBlockProfileCount(*getFunction(), BB); } -void BlockFrequencyInfo::setBlockFreq(const BasicBlock *BB, - uint64_t Freq) { +void BlockFrequencyInfo::setBlockFreq(const BasicBlock *BB, uint64_t Freq) { assert(BFI && "Expected analysis to be available"); BFI->setBlockFreq(BB, Freq); } diff --git a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp index fba82076ac2..90bc249bcb3 100644 --- a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp +++ b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp @@ -13,6 +13,7 @@ #include "llvm/Analysis/BlockFrequencyInfoImpl.h" #include "llvm/ADT/SCCIterator.h" +#include "llvm/IR/Function.h" #include "llvm/Support/raw_ostream.h" #include <numeric> @@ -529,6 +530,21 @@ BlockFrequencyInfoImplBase::getBlockFreq(const BlockNode &Node) const { return Freqs[Node.Index].Integer; } +Optional<uint64_t> +BlockFrequencyInfoImplBase::getBlockProfileCount(const Function &F, + const BlockNode &Node) const { + auto EntryCount = F.getEntryCount(); + if (!EntryCount) + return None; + // Use 128 bit APInt to do the arithmetic to avoid overflow. + APInt BlockCount(128, EntryCount.getValue()); + APInt BlockFreq(128, getBlockFreq(Node).getFrequency()); + APInt EntryFreq(128, getEntryFreq()); + BlockCount *= BlockFreq; + BlockCount = BlockCount.udiv(EntryFreq); + return BlockCount.getLimitedValue(); +} + Scaled64 BlockFrequencyInfoImplBase::getFloatingBlockFreq(const BlockNode &Node) const { if (!Node.isValid()) |

