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-02-21 17:27:13 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       55295 : INITIALIZE_PASS_BEGIN(LazyBranchProbabilityInfoPass, DEBUG_TYPE,
      26             :                       "Lazy Branch Probability Analysis", true, true)
      27       55295 : INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
      28       55295 : INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
      29      393968 : INITIALIZE_PASS_END(LazyBranchProbabilityInfoPass, DEBUG_TYPE,
      30             :                     "Lazy Branch Probability Analysis", true, true)
      31             : 
      32             : char LazyBranchProbabilityInfoPass::ID = 0;
      33             : 
      34       21407 : LazyBranchProbabilityInfoPass::LazyBranchProbabilityInfoPass()
      35       21407 :     : FunctionPass(ID) {
      36       21407 :   initializeLazyBranchProbabilityInfoPassPass(*PassRegistry::getPassRegistry());
      37       21407 : }
      38             : 
      39          32 : void LazyBranchProbabilityInfoPass::print(raw_ostream &OS,
      40             :                                           const Module *) const {
      41          32 :   LBPI->getCalculated().print(OS);
      42          32 : }
      43             : 
      44       21410 : void LazyBranchProbabilityInfoPass::getAnalysisUsage(AnalysisUsage &AU) const {
      45             :   AU.addRequired<LoopInfoWrapperPass>();
      46             :   AU.addRequired<TargetLibraryInfoWrapperPass>();
      47             :   AU.setPreservesAll();
      48       21410 : }
      49             : 
      50      726986 : void LazyBranchProbabilityInfoPass::releaseMemory() { LBPI.reset(); }
      51             : 
      52      363537 : bool LazyBranchProbabilityInfoPass::runOnFunction(Function &F) {
      53      363537 :   LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
      54      363537 :   TargetLibraryInfo &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
      55      363537 :   LBPI = llvm::make_unique<LazyBranchProbabilityInfo>(&F, &LI, &TLI);
      56      363537 :   return false;
      57             : }
      58             : 
      59       44109 : void LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AnalysisUsage &AU) {
      60             :   AU.addRequired<LazyBranchProbabilityInfoPass>();
      61             :   AU.addRequired<LoopInfoWrapperPass>();
      62             :   AU.addRequired<TargetLibraryInfoWrapperPass>();
      63       44109 : }
      64             : 
      65      110590 : void llvm::initializeLazyBPIPassPass(PassRegistry &Registry) {
      66      110590 :   INITIALIZE_PASS_DEPENDENCY(LazyBranchProbabilityInfoPass);
      67      110590 :   INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);
      68      110590 :   INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass);
      69      110590 : }

Generated by: LCOV version 1.13