LLVM  9.0.0svn
LazyBlockFrequencyInfo.cpp
Go to the documentation of this file.
1 //===- LazyBlockFrequencyInfo.cpp - Lazy Block Frequency Analysis ---------===//
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 // This is an alternative analysis pass to BlockFrequencyInfoWrapperPass. The
10 // difference is that with this pass the block frequencies are not computed when
11 // the analysis pass is executed but rather when the BFI result is explicitly
12 // requested by the analysis client.
13 //
14 //===----------------------------------------------------------------------===//
15 
18 #include "llvm/Analysis/LoopInfo.h"
19 #include "llvm/IR/Dominators.h"
20 
21 using namespace llvm;
22 
23 #define DEBUG_TYPE "lazy-block-freq"
24 
26  "Lazy Block Frequency Analysis", true, true)
27 INITIALIZE_PASS_DEPENDENCY(LazyBPIPass)
30  "Lazy Block Frequency Analysis", true, true)
31 
32 char LazyBlockFrequencyInfoPass::ID = 0;
33 
34 LazyBlockFrequencyInfoPass::LazyBlockFrequencyInfoPass() : FunctionPass(ID) {
36 }
37 
39  LBFI.getCalculated().print(OS);
40 }
41 
44  // We require DT so it's available when LI is available. The LI updating code
45  // asserts that DT is also present so if we don't make sure that we have DT
46  // here, that assert will trigger.
49  AU.setPreservesAll();
50 }
51 
52 void LazyBlockFrequencyInfoPass::releaseMemory() { LBFI.releaseMemory(); }
53 
55  auto &BPIPass = getAnalysis<LazyBranchProbabilityInfoPass>();
56  LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
57  LBFI.setAnalysis(&F, &BPIPass, &LI);
58  return false;
59 }
60 
65 }
66 
68  initializeLazyBPIPassPass(Registry);
71 }
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This is an alternative analysis pass to BlockFrequencyInfoWrapperPass.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:64
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:44
Lazy Block Frequency true
void initializeLazyBFIPassPass(PassRegistry &Registry)
Helper for client passes to initialize dependent passes for LBFI.
INITIALIZE_PASS_BEGIN(LazyBlockFrequencyInfoPass, DEBUG_TYPE, "Lazy Block Frequency Analysis", true, true) INITIALIZE_PASS_END(LazyBlockFrequencyInfoPass
static void getLazyBPIAnalysisUsage(AnalysisUsage &AU)
Helper for client passes to set up the analysis usage on behalf of this pass.
F(f)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:50
void initializeLazyBPIPassPass(PassRegistry &Registry)
Helper for client passes to initialize dependent passes for LBPI.
void initializeLazyBlockFrequencyInfoPassPass(PassRegistry &)
#define DEBUG_TYPE
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:284
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...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
void print(raw_ostream &OS, const Module *M) const override
print - Print out the internal state of the pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
static void getLazyBFIAnalysisUsage(AnalysisUsage &AU)
Helper for client passes to set up the analysis usage on behalf of this pass.
Lazy Block Frequency Analysis
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
The legacy pass manager&#39;s analysis pass to compute loop information.
Definition: LoopInfo.h:969
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:38
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:259
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...