[Thumb1] AND with a constant operand can be converted into BIC
[llvm-core.git] / lib / Analysis / LazyBranchProbabilityInfo.cpp
blobb51c6beb795928277a674f70d50fd7b109fecb50
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.
15 //===----------------------------------------------------------------------===//
17 #include "llvm/Analysis/LazyBranchProbabilityInfo.h"
18 #include "llvm/Analysis/LoopInfo.h"
20 using namespace llvm;
22 #define DEBUG_TYPE "lazy-branch-prob"
24 INITIALIZE_PASS_BEGIN(LazyBranchProbabilityInfoPass, DEBUG_TYPE,
25 "Lazy Branch Probability Analysis", true, true)
26 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
27 INITIALIZE_PASS_END(LazyBranchProbabilityInfoPass, DEBUG_TYPE,
28 "Lazy Branch Probability Analysis", true, true)
30 char LazyBranchProbabilityInfoPass::ID = 0;
32 LazyBranchProbabilityInfoPass::LazyBranchProbabilityInfoPass()
33 : FunctionPass(ID) {
34 initializeLazyBranchProbabilityInfoPassPass(*PassRegistry::getPassRegistry());
37 void LazyBranchProbabilityInfoPass::print(raw_ostream &OS,
38 const Module *) const {
39 LBPI->getCalculated().print(OS);
42 void LazyBranchProbabilityInfoPass::getAnalysisUsage(AnalysisUsage &AU) const {
43 AU.addRequired<LoopInfoWrapperPass>();
44 AU.setPreservesAll();
47 void LazyBranchProbabilityInfoPass::releaseMemory() { LBPI.reset(); }
49 bool LazyBranchProbabilityInfoPass::runOnFunction(Function &F) {
50 LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
51 LBPI = llvm::make_unique<LazyBranchProbabilityInfo>(&F, &LI);
52 return false;
55 void LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AnalysisUsage &AU) {
56 AU.addRequired<LazyBranchProbabilityInfoPass>();
57 AU.addRequired<LoopInfoWrapperPass>();
60 void llvm::initializeLazyBPIPassPass(PassRegistry &Registry) {
61 INITIALIZE_PASS_DEPENDENCY(LazyBranchProbabilityInfoPass);
62 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);