1 //========-------- BlockFrequency.h - Block Frequency Analysis -------========//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Loops should be simplified before this analysis.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ANALYSIS_BLOCKFREQUENCY_H
15 #define LLVM_ANALYSIS_BLOCKFREQUENCY_H
17 #include "llvm/Pass.h"
22 class BranchProbabilityInfo;
23 template<class BlockT, class FunctionT, class BranchProbInfoT>
24 class BlockFrequencyImpl;
26 /// BlockFrequency pass uses BlockFrequencyImpl implementation to estimate
27 /// IR basic block frequencies.
28 class BlockFrequency : public FunctionPass {
30 BlockFrequencyImpl<BasicBlock, Function, BranchProbabilityInfo> *BFI;
39 void getAnalysisUsage(AnalysisUsage &AU) const;
41 bool runOnFunction(Function &F);
43 /// getblockFreq - Return block frequency. Never return 0, value must be
44 /// positive. Please note that initial frequency is equal to 1024. It means
45 /// that we should not rely on the value itself, but only on the comparison to
46 /// the other block frequencies. We do this to avoid using of the floating
48 uint32_t getBlockFreq(BasicBlock *BB);