LLVM  4.0.0
LazyBranchProbabilityInfo.cpp
Go to the documentation of this file.
1 //===- LazyBranchProbabilityInfo.cpp - Lazy Branch Probability Analysis ---===//
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 // This is an alternative analysis pass to BranchProbabilityInfoWrapperPass.
11 // The difference is that with this pass the branch probabilities are not
12 // computed when the analysis pass is executed but rather when the BPI results
13 // is explicitly requested by the analysis client.
14 //
15 //===----------------------------------------------------------------------===//
16 
18 #include "llvm/Analysis/LoopInfo.h"
19 
20 using namespace llvm;
21 
22 #define DEBUG_TYPE "lazy-branch-prob"
23 
25  "Lazy Branch Probability Analysis", true, true)
28  "Lazy Branch Probability Analysis", true, true)
29 
30 char LazyBranchProbabilityInfoPass::ID = 0;
31 
32 LazyBranchProbabilityInfoPass::LazyBranchProbabilityInfoPass()
33  : FunctionPass(ID) {
35 }
36 
38  const Module *) const {
39  LBPI->getCalculated().print(OS);
40 }
41 
44  AU.setPreservesAll();
45 }
46 
48 
50  LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
51  LBPI = llvm::make_unique<LazyBranchProbabilityInfo>(&F, &LI);
52  return false;
53 }
54 
58 }
59 
63 }
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:45
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
static void getLazyBPIAnalysisUsage(AnalysisUsage &AU)
Helper for client passes to set up the analysis usage on behalf of this pass.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:53
This is an alternative analysis pass to BranchProbabilityInfoWrapperPass.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Lazy Branch Probability Analysis
#define DEBUG_TYPE
#define F(x, y, z)
Definition: MD5.cpp:51
void initializeLazyBPIPassPass(PassRegistry &Registry)
Helper for client passes to initialize dependent passes for LBPI.
void initializeLazyBranchProbabilityInfoPassPass(PassRegistry &)
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
Represent the analysis usage information of a pass.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
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.
INITIALIZE_PASS_BEGIN(LazyBranchProbabilityInfoPass, DEBUG_TYPE,"Lazy Branch Probability Analysis", true, true) INITIALIZE_PASS_END(LazyBranchProbabilityInfoPass
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
The legacy pass manager's analysis pass to compute loop information.
Definition: LoopInfo.h:831
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:40
Lazy Branch Probability true