LCOV - code coverage report
Current view: top level - lib/Analysis - LazyBranchProbabilityInfo.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 26 26 100.0 %
Date: 2018-05-20 00:06:23 Functions: 9 9 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      17             : #include "llvm/Analysis/LazyBranchProbabilityInfo.h"
      18             : #include "llvm/Analysis/LoopInfo.h"
      19             : #include "llvm/Analysis/TargetLibraryInfo.h"
      20             : #include "llvm/IR/Dominators.h"
      21             : 
      22             : using namespace llvm;
      23             : 
      24             : #define DEBUG_TYPE "lazy-branch-prob"
      25             : 
      26       55922 : INITIALIZE_PASS_BEGIN(LazyBranchProbabilityInfoPass, DEBUG_TYPE,
      27             :                       "Lazy Branch Probability Analysis", true, true)
      28       55922 : INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
      29       55922 : INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
      30      400802 : INITIALIZE_PASS_END(LazyBranchProbabilityInfoPass, DEBUG_TYPE,
      31             :                     "Lazy Branch Probability Analysis", true, true)
      32             : 
      33             : char LazyBranchProbabilityInfoPass::ID = 0;
      34             : 
      35       22467 : LazyBranchProbabilityInfoPass::LazyBranchProbabilityInfoPass()
      36       22467 :     : FunctionPass(ID) {
      37       22467 :   initializeLazyBranchProbabilityInfoPassPass(*PassRegistry::getPassRegistry());
      38       22467 : }
      39             : 
      40          32 : void LazyBranchProbabilityInfoPass::print(raw_ostream &OS,
      41             :                                           const Module *) const {
      42          32 :   LBPI->getCalculated().print(OS);
      43          32 : }
      44             : 
      45       22470 : void LazyBranchProbabilityInfoPass::getAnalysisUsage(AnalysisUsage &AU) const {
      46             :   // We require DT so it's available when LI is available. The LI updating code
      47             :   // asserts that DT is also present so if we don't make sure that we have DT
      48             :   // here, that assert will trigger.
      49             :   AU.addRequired<DominatorTreeWrapperPass>();
      50             :   AU.addRequired<LoopInfoWrapperPass>();
      51             :   AU.addRequired<TargetLibraryInfoWrapperPass>();
      52             :   AU.setPreservesAll();
      53       22470 : }
      54             : 
      55      739822 : void LazyBranchProbabilityInfoPass::releaseMemory() { LBPI.reset(); }
      56             : 
      57      369955 : bool LazyBranchProbabilityInfoPass::runOnFunction(Function &F) {
      58      369955 :   LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
      59      369955 :   TargetLibraryInfo &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
      60      369955 :   LBPI = llvm::make_unique<LazyBranchProbabilityInfo>(&F, &LI, &TLI);
      61      369955 :   return false;
      62             : }
      63             : 
      64       46326 : void LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AnalysisUsage &AU) {
      65             :   AU.addRequired<LazyBranchProbabilityInfoPass>();
      66             :   AU.addRequired<LoopInfoWrapperPass>();
      67             :   AU.addRequired<TargetLibraryInfoWrapperPass>();
      68       46326 : }
      69             : 
      70      111844 : void llvm::initializeLazyBPIPassPass(PassRegistry &Registry) {
      71      111844 :   INITIALIZE_PASS_DEPENDENCY(LazyBranchProbabilityInfoPass);
      72      111844 :   INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);
      73      111844 :   INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass);
      74      111844 : }

Generated by: LCOV version 1.13