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 | 7f4f1f640d2b5abf8e8f1cade3d42d4f02b75b89 (patch) | |
| tree | 2681e4766f25c677461525f89fa867dc37ec2246 /lib/Analysis | |
| parent | 464847757fd99da9f1347871f9bc71c37df4b0ef (diff) | |
[BFI]: NFC refactoring
move getBlockProfileCount implementation to the
base class so that MBFI can share too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
| -rw-r--r-- | lib/Analysis/BlockFrequencyInfo.cpp | 15 | ||||
| -rw-r--r-- | lib/Analysis/BlockFrequencyInfoImpl.cpp | 16 |
2 files changed, 20 insertions, 11 deletions
diff --git a/lib/Analysis/BlockFrequencyInfo.cpp b/lib/Analysis/BlockFrequencyInfo.cpp index a0c472d7c72..ac7f6e28b3d 100644 --- a/lib/Analysis/BlockFrequencyInfo.cpp +++ b/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/lib/Analysis/BlockFrequencyInfoImpl.cpp b/lib/Analysis/BlockFrequencyInfoImpl.cpp index fba82076ac2..90bc249bcb3 100644 --- a/lib/Analysis/BlockFrequencyInfoImpl.cpp +++ b/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()) |
