LLVM  3.7.0
BlockFrequencyInfo.h
Go to the documentation of this file.
1 //===- BlockFrequencyInfo.h - Block Frequency Analysis ----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Loops should be simplified before this analysis.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_ANALYSIS_BLOCKFREQUENCYINFO_H
15 #define LLVM_ANALYSIS_BLOCKFREQUENCYINFO_H
16 
17 #include "llvm/Pass.h"
19 #include <climits>
20 
21 namespace llvm {
22 
23 class BranchProbabilityInfo;
24 template <class BlockT> class BlockFrequencyInfoImpl;
25 
26 /// BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to
27 /// estimate IR basic block frequencies.
30  std::unique_ptr<ImplType> BFI;
31 
32 public:
33  static char ID;
34 
36 
37  ~BlockFrequencyInfo() override;
38 
39  void getAnalysisUsage(AnalysisUsage &AU) const override;
40 
41  bool runOnFunction(Function &F) override;
42  void releaseMemory() override;
43  void print(raw_ostream &O, const Module *M) const override;
44  const Function *getFunction() const;
45  void view() const;
46 
47  /// getblockFreq - Return block frequency. Return 0 if we don't have the
48  /// information. Please note that initial frequency is equal to ENTRY_FREQ. It
49  /// means that we should not rely on the value itself, but only on the
50  /// comparison to the other block frequencies. We do this to avoid using of
51  /// floating points.
52  BlockFrequency getBlockFreq(const BasicBlock *BB) const;
53 
54  // Print the block frequency Freq to OS using the current functions entry
55  // frequency to convert freq into a relative decimal form.
56  raw_ostream &printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const;
57 
58  // Convenience method that attempts to look up the frequency associated with
59  // BB and print it to OS.
60  raw_ostream &printBlockFreq(raw_ostream &OS, const BasicBlock *BB) const;
61 
62  uint64_t getEntryFreq() const;
63 
64 };
65 
66 }
67 
68 #endif
raw_ostream & printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
F(f)
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
void print(raw_ostream &O, const Module *M) const override
print - Print out the internal state of the pass.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
LLVM Basic Block Representation.
Definition: BasicBlock.h:65
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:294
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
const Function * getFunction() const
void view() const
Pop up a ghostview window with the current block frequency propagation rendered using dot...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
Shared implementation for block frequency analysis.
BlockFrequency getBlockFreq(const BasicBlock *BB) const
getblockFreq - Return block frequency.