LLVM  9.0.0svn
MachineBlockFrequencyInfo.h
Go to the documentation of this file.
1 //===- MachineBlockFrequencyInfo.h - MBB Frequency Analysis -----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Loops should be simplified before this analysis.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
14 #define LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
15 
16 #include "llvm/ADT/Optional.h"
19 #include <cstdint>
20 #include <memory>
21 
22 namespace llvm {
23 
24 template <class BlockT> class BlockFrequencyInfoImpl;
25 class MachineBasicBlock;
26 class MachineBranchProbabilityInfo;
27 class MachineFunction;
28 class MachineLoopInfo;
29 class raw_ostream;
30 
31 /// MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation
32 /// to estimate machine basic block frequencies.
35  std::unique_ptr<ImplType> MBFI;
36 
37 public:
38  static char ID;
39 
41  ~MachineBlockFrequencyInfo() override;
42 
43  void getAnalysisUsage(AnalysisUsage &AU) const override;
44 
45  bool runOnMachineFunction(MachineFunction &F) override;
46 
47  /// calculate - compute block frequency info for the given function.
48  void calculate(const MachineFunction &F,
49  const MachineBranchProbabilityInfo &MBPI,
50  const MachineLoopInfo &MLI);
51 
52  void releaseMemory() override;
53 
54  /// getblockFreq - Return block frequency. Return 0 if we don't have the
55  /// information. Please note that initial frequency is equal to 1024. It means
56  /// that we should not rely on the value itself, but only on the comparison to
57  /// the other block frequencies. We do this to avoid using of floating points.
58  ///
60 
62  Optional<uint64_t> getProfileCountFromFreq(uint64_t Freq) const;
63 
64  bool isIrrLoopHeader(const MachineBasicBlock *MBB);
65 
66  const MachineFunction *getFunction() const;
68  void view(const Twine &Name, bool isSimple = true) const;
69 
70  // Print the block frequency Freq to OS using the current functions entry
71  // frequency to convert freq into a relative decimal form.
72  raw_ostream &printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const;
73 
74  // Convenience method that attempts to look up the frequency associated with
75  // BB and print it to OS.
77  const MachineBasicBlock *MBB) const;
78 
79  uint64_t getEntryFreq() const;
80 };
81 
82 } // end namespace llvm
83 
84 #endif // LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
F(f)
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:80
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:45
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.