LCOV - code coverage report
Current view: top level - lib/Analysis - LazyBranchProbabilityInfo.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 32 32 100.0 %
Date: 2017-09-14 15:23:50 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             : 
      21             : using namespace llvm;
      22             : 
      23             : #define DEBUG_TYPE "lazy-branch-prob"
      24             : 
      25       41843 : INITIALIZE_PASS_BEGIN(LazyBranchProbabilityInfoPass, DEBUG_TYPE,
      26             :                       "Lazy Branch Probability Analysis", true, true)
      27       41843 : INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
      28       41843 : INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
      29      420052 : INITIALIZE_PASS_END(LazyBranchProbabilityInfoPass, DEBUG_TYPE,
      30             :                     "Lazy Branch Probability Analysis", true, true)
      31             : 
      32             : char LazyBranchProbabilityInfoPass::ID = 0;
      33             : 
      34       19278 : LazyBranchProbabilityInfoPass::LazyBranchProbabilityInfoPass()
      35       57834 :     : FunctionPass(ID) {
      36       19278 :   initializeLazyBranchProbabilityInfoPassPass(*PassRegistry::getPassRegistry());
      37       19278 : }
      38             : 
      39          32 : void LazyBranchProbabilityInfoPass::print(raw_ostream &OS,
      40             :                                           const Module *) const {
      41          96 :   LBPI->getCalculated().print(OS);
      42          32 : }
      43             : 
      44       19281 : void LazyBranchProbabilityInfoPass::getAnalysisUsage(AnalysisUsage &AU) const {
      45       19281 :   AU.addRequired<LoopInfoWrapperPass>();
      46       19281 :   AU.addRequired<TargetLibraryInfoWrapperPass>();
      47       19281 :   AU.setPreservesAll();
      48       19281 : }
      49             : 
      50      734260 : void LazyBranchProbabilityInfoPass::releaseMemory() { LBPI.reset(); }
      51             : 
      52      367174 : bool LazyBranchProbabilityInfoPass::runOnFunction(Function &F) {
      53      734348 :   LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
      54      734348 :   TargetLibraryInfo &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
      55      367174 :   LBPI = llvm::make_unique<LazyBranchProbabilityInfo>(&F, &LI, &TLI);
      56      367174 :   return false;
      57             : }
      58             : 
      59       39527 : void LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AnalysisUsage &AU) {
      60       39527 :   AU.addRequired<LazyBranchProbabilityInfoPass>();
      61       39527 :   AU.addRequired<LoopInfoWrapperPass>();
      62       39527 :   AU.addRequired<TargetLibraryInfoWrapperPass>();
      63       39527 : }
      64             : 
      65       83686 : void llvm::initializeLazyBPIPassPass(PassRegistry &Registry) {
      66       83686 :   INITIALIZE_PASS_DEPENDENCY(LazyBranchProbabilityInfoPass);
      67       83686 :   INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);
      68       83686 :   INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass);
      69       83686 : }

Generated by: LCOV version 1.13