diff options
author | Jakub Staszak <jstaszak@apple.com> | 2011-06-23 21:45:20 +0000 |
---|---|---|
committer | Jakub Staszak <jstaszak@apple.com> | 2011-06-23 21:45:20 +0000 |
commit | 44eb49c2a191108df801977c8e3dc03466c6c02a (patch) | |
tree | b51888831a9e6a115cf5d8c57d5c4664669eb322 /include | |
parent | a390a1aa48d8fa5085aa51b950f00d79dbb0c646 (diff) |
Introduce BlockFrequency analysis for BasicBlocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133766 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Analysis/BranchProbabilityInfo.h | 10 | ||||
-rw-r--r-- | include/llvm/InitializePasses.h | 1 | ||||
-rw-r--r-- | include/llvm/Support/BranchProbability.h | 10 |
3 files changed, 20 insertions, 1 deletions
diff --git a/include/llvm/Analysis/BranchProbabilityInfo.h b/include/llvm/Analysis/BranchProbabilityInfo.h index 5a17a76f5b..e40d2044dc 100644 --- a/include/llvm/Analysis/BranchProbabilityInfo.h +++ b/include/llvm/Analysis/BranchProbabilityInfo.h @@ -39,6 +39,9 @@ class BranchProbabilityInfo : public FunctionPass { // Get sum of the block successors' weights. uint32_t getSumForBlock(BasicBlock *BB) const; + // Get sum of the edge weights going to the BB block. + uint32_t getBackSumForBlock(BasicBlock *BB) const; + public: static char ID; @@ -71,6 +74,13 @@ public: // only iff SRC block has only one successor. BranchProbability getEdgeProbability(BasicBlock *Src, BasicBlock *Dst) const; + // Return a probability of getting to the DST block through SRC->DST edge. + // Returned value is a fraction between 0 (0% probability) and + // 1 (100% probability), however the value is never equal to 0, and can be 1 + // only iff DST block has only one predecesor. + BranchProbability getBackEdgeProbability(BasicBlock *Src, + BasicBlock *Dst) const; + // Print value between 0 (0% probability) and 1 (100% probability), // however the value is never equal to 0, and can be 1 only iff SRC block // has only one successor. diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index 5efdcc9976..5dfc4b3ceb 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -65,6 +65,7 @@ void initializeArgPromotionPass(PassRegistry&); void initializeBasicAliasAnalysisPass(PassRegistry&); void initializeBasicCallGraphPass(PassRegistry&); void initializeBlockExtractorPassPass(PassRegistry&); +void initializeBlockFrequencyPass(PassRegistry&); void initializeBlockPlacementPass(PassRegistry&); void initializeBranchProbabilityInfoPass(PassRegistry&); void initializeBreakCriticalEdgesPass(PassRegistry&); diff --git a/include/llvm/Support/BranchProbability.h b/include/llvm/Support/BranchProbability.h index 7ba649133b..c66d224886 100644 --- a/include/llvm/Support/BranchProbability.h +++ b/include/llvm/Support/BranchProbability.h @@ -18,13 +18,17 @@ namespace llvm { -class raw_ostream; +template<class BlockT, class FunctionT, class BranchProbInfoT> +class BlockFrequencyImpl; class BranchProbabilityInfo; class MachineBranchProbabilityInfo; class MachineBasicBlock; +class raw_ostream; // This class represents Branch Probability as a non-negative fraction. class BranchProbability { + template<class BlockT, class FunctionT, class BranchProbInfoT> + friend class BlockFrequencyImpl; friend class BranchProbabilityInfo; friend class MachineBranchProbabilityInfo; friend class MachineBasicBlock; @@ -38,6 +42,10 @@ class BranchProbability { BranchProbability(uint32_t n, uint32_t d); public: + + uint32_t getNumerator() const { return N; } + uint32_t getDenominator() const { return D; } + raw_ostream &print(raw_ostream &OS) const; void dump() const; |