LLVM 24.0.0git
LazyMachineBlockFrequencyInfo.cpp
Go to the documentation of this file.
1///===- LazyMachineBlockFrequencyInfo.cpp - Lazy Machine Block Frequency --===//
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
20
21using namespace llvm;
22
23#define DEBUG_TYPE "lazy-machine-block-freq"
24
26 "Lazy Machine Block Frequency Analysis", true, true)
30 "Lazy Machine Block Frequency Analysis", true, true)
31
33
36
43
45 OwnedMBFI.reset();
46 OwnedMCI.reset();
47}
48
50LazyMachineBlockFrequencyInfoPass::calculateIfNotAvailable() const {
51 auto *MBFIWrapper =
53 if (MBFIWrapper) {
54 LLVM_DEBUG(dbgs() << "MachineBlockFrequencyInfo is available\n");
55 return MBFIWrapper->getMBFI();
56 }
57
60 auto *MCI = MCIWrapper ? &MCIWrapper->getCycleInfo() : nullptr;
61 LLVM_DEBUG(dbgs() << "Building MachineBlockFrequencyInfo on the fly\n");
62 LLVM_DEBUG(if (MCI) dbgs() << "CycleInfo is available\n");
63
64 if (!MCI) {
65 LLVM_DEBUG(dbgs() << "Building CycleInfo on the fly\n");
66 OwnedMCI = std::make_unique<MachineCycleInfo>();
67 OwnedMCI->compute(*MF);
68 MCI = OwnedMCI.get();
69 }
70
71 OwnedMBFI = std::make_unique<MachineBlockFrequencyInfo>();
72 OwnedMBFI->calculate(*MF, MBPI, *MCI);
73 return *OwnedMBFI;
74}
75
#define DEBUG_TYPE
===- LazyMachineBlockFrequencyInfo.h - Lazy Block Frequency -*- C++ -*–===//
#define F(x, y, z)
Definition MD5.cpp:54
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition PassSupport.h:42
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition PassSupport.h:39
#define LLVM_DEBUG(...)
Definition Debug.h:119
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
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...
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...
const MachineBlockFrequencyInfo & getMBFI() const
Definition MBFIWrapper.h:37
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
Legacy analysis pass which computes a MachineCycleInfo.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
AnalysisType * getAnalysisIfAvailable() const
getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information tha...
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209