1 //========-------- BlockFrequencyInfo.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_BLOCKFREQUENCYINFO_H
15 #define LLVM_ANALYSIS_BLOCKFREQUENCYINFO_H
17 #include "llvm/Pass.h"
18 #include "llvm/Support/BlockFrequency.h"
23 class BranchProbabilityInfo;
24 template<class BlockT, class FunctionT, class BranchProbInfoT>
25 class BlockFrequencyImpl;
27 /// BlockFrequencyInfo pass uses BlockFrequencyImpl implementation to estimate
28 /// IR basic block frequencies.
29 class BlockFrequencyInfo : public FunctionPass {
31 BlockFrequencyImpl<BasicBlock, Function, BranchProbabilityInfo> *BFI;
38 ~BlockFrequencyInfo();
40 void getAnalysisUsage(AnalysisUsage &AU) const;
42 bool runOnFunction(Function &F);
43 void print(raw_ostream &O, const Module *M) const;
45 /// getblockFreq - Return block frequency. Return 0 if we don't have the
46 /// information. Please note that initial frequency is equal to ENTRY_FREQ. It
47 /// means that we should not rely on the value itself, but only on the
48 /// comparison to the other block frequencies. We do this to avoid using of
50 BlockFrequency getBlockFreq(const BasicBlock *BB) const;