diff options
author | Easwaran Raman <eraman@google.com> | 2016-03-23 18:18:26 +0000 |
---|---|---|
committer | Easwaran Raman <eraman@google.com> | 2016-03-23 18:18:26 +0000 |
commit | 12b79aa0f1b7aa6e792a0b65d219a969f4ea8f0b (patch) | |
tree | 8661b501acc2524157130488c0e91e2797d73f58 /llvm/include | |
parent | d1728f0e5f5f4ab236febf2ae96949a974dca83a (diff) | |
download | bcm5719-llvm-12b79aa0f1b7aa6e792a0b65d219a969f4ea8f0b.tar.gz bcm5719-llvm-12b79aa0f1b7aa6e792a0b65d219a969f4ea8f0b.zip |
Add getBlockProfileCount method to BlockFrequencyInfo
Differential Revision: http://reviews.llvm.org/D18233
llvm-svn: 264179
Diffstat (limited to 'llvm/include')
-rw-r--r-- | llvm/include/llvm/Analysis/BlockFrequencyInfo.h | 6 | ||||
-rw-r--r-- | llvm/include/llvm/ProfileData/ProfileCommon.h | 13 |
2 files changed, 6 insertions, 13 deletions
diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfo.h b/llvm/include/llvm/Analysis/BlockFrequencyInfo.h index 6f2a2b52276..875775439b1 100644 --- a/llvm/include/llvm/Analysis/BlockFrequencyInfo.h +++ b/llvm/include/llvm/Analysis/BlockFrequencyInfo.h @@ -14,6 +14,7 @@ #ifndef LLVM_ANALYSIS_BLOCKFREQUENCYINFO_H #define LLVM_ANALYSIS_BLOCKFREQUENCYINFO_H +#include "llvm/ADT/Optional.h" #include "llvm/Pass.h" #include "llvm/Support/BlockFrequency.h" #include <climits> @@ -45,6 +46,11 @@ public: /// floating points. BlockFrequency getBlockFreq(const BasicBlock *BB) const; + /// \brief Returns the estimated profile count of \p BB. + /// This computes the relative block frequency of \p BB and multiplies it by + /// the enclosing function's count (if available) and returns the value. + Optional<uint64_t> getBlockProfileCount(const BasicBlock *BB) const; + // Set the frequency of the given basic block. void setBlockFreq(const BasicBlock *BB, uint64_t Freq); diff --git a/llvm/include/llvm/ProfileData/ProfileCommon.h b/llvm/include/llvm/ProfileData/ProfileCommon.h index a7ac78d2523..eb14369e413 100644 --- a/llvm/include/llvm/ProfileData/ProfileCommon.h +++ b/llvm/include/llvm/ProfileData/ProfileCommon.h @@ -185,18 +185,5 @@ SummaryEntryVector &ProfileSummary::getDetailedSummary() { return DetailedSummary; } -/// Helper to compute the profile count for a block, based on the -/// ratio of its frequency to the entry block frequency, multiplied -/// by the entry block count. -inline uint64_t getBlockProfileCount(uint64_t BlockFreq, uint64_t EntryFreq, - uint64_t EntryCount) { - APInt ScaledCount(128, EntryCount); - APInt BlockFreqAPInt(128, BlockFreq); - APInt EntryFreqAPInt(128, EntryFreq); - ScaledCount *= BlockFreqAPInt; - ScaledCount = ScaledCount.udiv(EntryFreqAPInt); - return ScaledCount.getLimitedValue(); -} - } // end namespace llvm #endif |