LLVM 20.0.0git
LazyMachineBlockFrequencyInfo.h
Go to the documentation of this file.
1///===- LazyMachineBlockFrequencyInfo.h - Lazy Block Frequency -*- 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/// \file
9/// This is an alternative analysis pass to MachineBlockFrequencyInfo. The
10/// difference is that with this pass the block frequencies are not computed
11/// when the analysis pass is executed but rather when the BFI result is
12/// explicitly requested by the analysis client.
13///
14///===---------------------------------------------------------------------===//
15
16#ifndef LLVM_CODEGEN_LAZYMACHINEBLOCKFREQUENCYINFO_H
17#define LLVM_CODEGEN_LAZYMACHINEBLOCKFREQUENCYINFO_H
18
23
24namespace llvm {
25/// This is an alternative analysis pass to MachineBlockFrequencyInfo.
26/// The difference is that with this pass, the block frequencies are not
27/// computed when the analysis pass is executed but rather when the BFI result
28/// is explicitly requested by the analysis client.
29///
30/// This works by checking querying if MBFI is available and otherwise
31/// generating MBFI on the fly. In this case the passes required for (LI, DT)
32/// are also queried before being computed on the fly.
33///
34/// Note that it is expected that we wouldn't need this functionality for the
35/// new PM since with the new PM, analyses are executed on demand.
36
38private:
39 /// If generated on the fly this own the instance.
40 mutable std::unique_ptr<MachineBlockFrequencyInfo> OwnedMBFI;
41
42 /// If generated on the fly this own the instance.
43 mutable std::unique_ptr<MachineLoopInfo> OwnedMLI;
44
45 /// If generated on the fly this own the instance.
46 mutable std::unique_ptr<MachineDominatorTree> OwnedMDT;
47
48 /// The function.
49 MachineFunction *MF = nullptr;
50
51 /// Calculate MBFI and all other analyses that's not available and
52 /// required by BFI.
53 MachineBlockFrequencyInfo &calculateIfNotAvailable() const;
54
55public:
56 static char ID;
57
59
60 /// Compute and return the block frequencies.
61 MachineBlockFrequencyInfo &getBFI() { return calculateIfNotAvailable(); }
62
63 /// Compute and return the block frequencies.
65 return calculateIfNotAvailable();
66 }
67
68 void getAnalysisUsage(AnalysisUsage &AU) const override;
69
71 void releaseMemory() override;
72};
73}
74#endif
#define F(x, y, z)
Definition: MD5.cpp:55
Represent the analysis usage information of a pass.
This is an alternative analysis pass to MachineBlockFrequencyInfo.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
MachineBlockFrequencyInfo & getBFI()
Compute and return the block frequencies.
const MachineBlockFrequencyInfo & getBFI() const
Compute and return the block frequencies.
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...
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18