[ARM] Generate 8.1-m CSINC, CSNEG and CSINV instructions.
[llvm-core.git] / lib / Analysis / LazyBlockFrequencyInfo.cpp
blob439758560284171e008fbe7e66f0f4b2666364dd
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.
14 //===----------------------------------------------------------------------===//
16 #include "llvm/Analysis/LazyBlockFrequencyInfo.h"
17 #include "llvm/Analysis/LazyBranchProbabilityInfo.h"
18 #include "llvm/Analysis/LoopInfo.h"
19 #include "llvm/IR/Dominators.h"
21 using namespace llvm;
23 #define DEBUG_TYPE "lazy-block-freq"
25 INITIALIZE_PASS_BEGIN(LazyBlockFrequencyInfoPass, DEBUG_TYPE,
26 "Lazy Block Frequency Analysis", true, true)
27 INITIALIZE_PASS_DEPENDENCY(LazyBPIPass)
28 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
29 INITIALIZE_PASS_END(LazyBlockFrequencyInfoPass, DEBUG_TYPE,
30 "Lazy Block Frequency Analysis", true, true)
32 char LazyBlockFrequencyInfoPass::ID = 0;
34 LazyBlockFrequencyInfoPass::LazyBlockFrequencyInfoPass() : FunctionPass(ID) {
35 initializeLazyBlockFrequencyInfoPassPass(*PassRegistry::getPassRegistry());
38 void LazyBlockFrequencyInfoPass::print(raw_ostream &OS, const Module *) const {
39 LBFI.getCalculated().print(OS);
42 void LazyBlockFrequencyInfoPass::getAnalysisUsage(AnalysisUsage &AU) const {
43 LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AU);
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.
47 AU.addRequired<DominatorTreeWrapperPass>();
48 AU.addRequired<LoopInfoWrapperPass>();
49 AU.setPreservesAll();
52 void LazyBlockFrequencyInfoPass::releaseMemory() { LBFI.releaseMemory(); }
54 bool LazyBlockFrequencyInfoPass::runOnFunction(Function &F) {
55 auto &BPIPass = getAnalysis<LazyBranchProbabilityInfoPass>();
56 LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
57 LBFI.setAnalysis(&F, &BPIPass, &LI);
58 return false;
61 void LazyBlockFrequencyInfoPass::getLazyBFIAnalysisUsage(AnalysisUsage &AU) {
62 LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AU);
63 AU.addRequired<LazyBlockFrequencyInfoPass>();
64 AU.addRequired<LoopInfoWrapperPass>();
67 void llvm::initializeLazyBFIPassPass(PassRegistry &Registry) {
68 initializeLazyBPIPassPass(Registry);
69 INITIALIZE_PASS_DEPENDENCY(LazyBlockFrequencyInfoPass);
70 INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);