LLVM  8.0.1
MachineBlockFrequencyInfo.h
Go to the documentation of this file.
1 //===- MachineBlockFrequencyInfo.h - MBB 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_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
15 #define LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
16 
17 #include "llvm/ADT/Optional.h"
20 #include <cstdint>
21 #include <memory>
22 
23 namespace llvm {
24 
25 template <class BlockT> class BlockFrequencyInfoImpl;
26 class MachineBasicBlock;
27 class MachineBranchProbabilityInfo;
28 class MachineFunction;
29 class MachineLoopInfo;
30 class raw_ostream;
31 
32 /// MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation
33 /// to estimate machine basic block frequencies.
36  std::unique_ptr<ImplType> MBFI;
37 
38 public:
39  static char ID;
40 
42  ~MachineBlockFrequencyInfo() override;
43 
44  void getAnalysisUsage(AnalysisUsage &AU) const override;
45 
46  bool runOnMachineFunction(MachineFunction &F) override;
47 
48  /// calculate - compute block frequency info for the given function.
49  void calculate(const MachineFunction &F,
50  const MachineBranchProbabilityInfo &MBPI,
51  const MachineLoopInfo &MLI);
52 
53  void releaseMemory() override;
54 
55  /// getblockFreq - Return block frequency. Return 0 if we don't have the
56  /// information. Please note that initial frequency is equal to 1024. It means
57  /// that we should not rely on the value itself, but only on the comparison to
58  /// the other block frequencies. We do this to avoid using of floating points.
59  ///
61 
63  Optional<uint64_t> getProfileCountFromFreq(uint64_t Freq) const;
64 
65  bool isIrrLoopHeader(const MachineBasicBlock *MBB);
66 
67  const MachineFunction *getFunction() const;
69  void view(const Twine &Name, bool isSimple = true) const;
70 
71  // Print the block frequency Freq to OS using the current functions entry
72  // frequency to convert freq into a relative decimal form.
73  raw_ostream &printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const;
74 
75  // Convenience method that attempts to look up the frequency associated with
76  // BB and print it to OS.
78  const MachineBasicBlock *MBB) const;
79 
80  uint64_t getEntryFreq() const;
81 };
82 
83 } // end namespace llvm
84 
85 #endif // LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
F(f)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
void view(const Twine &Name, bool isSimple=true) const
Pop up a ghostview window with the current block frequency propagation rendered using dot...
static bool isSimple(Instruction *I)
Optional< uint64_t > getBlockProfileCount(const MachineBasicBlock *MBB) const
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
getblockFreq - Return block frequency.
raw_ostream & printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const
Represent the analysis usage information of a pass.
const MachineBranchProbabilityInfo * getMBPI() const
const MachineFunction * getFunction() const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
bool runOnMachineFunction(MachineFunction &F) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Optional< uint64_t > getProfileCountFromFreq(uint64_t Freq) const
bool isIrrLoopHeader(const MachineBasicBlock *MBB)
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
void calculate(const MachineFunction &F, const MachineBranchProbabilityInfo &MBPI, const MachineLoopInfo &MLI)
calculate - compute block frequency info for the given function.
Shared implementation for block frequency analysis.