LCOV - code coverage report
Current view: top level - lib/Analysis - LazyBlockFrequencyInfo.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             : //===- LazyBlockFrequencyInfo.cpp - Lazy Block Frequency 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 BlockFrequencyInfoWrapperPass.  The
      11             : // difference is that with this pass the block frequencies are not computed when
      12             : // the analysis pass is executed but rather when the BFI result is explicitly
      13             : // requested by the analysis client.
      14             : //
      15             : //===----------------------------------------------------------------------===//
      16             : 
      17             : #include "llvm/Analysis/LazyBlockFrequencyInfo.h"
      18             : #include "llvm/Analysis/LazyBranchProbabilityInfo.h"
      19             : #include "llvm/Analysis/LoopInfo.h"
      20             : 
      21             : using namespace llvm;
      22             : 
      23             : #define DEBUG_TYPE "lazy-block-freq"
      24             : 
      25       55295 : INITIALIZE_PASS_BEGIN(LazyBlockFrequencyInfoPass, DEBUG_TYPE,
      26             :                       "Lazy Block Frequency Analysis", true, true)
      27       55295 : INITIALIZE_PASS_DEPENDENCY(LazyBPIPass)
      28       55295 : INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
      29      283374 : INITIALIZE_PASS_END(LazyBlockFrequencyInfoPass, DEBUG_TYPE,
      30             :                     "Lazy Block Frequency Analysis", true, true)
      31             : 
      32             : char LazyBlockFrequencyInfoPass::ID = 0;
      33             : 
      34       42810 : LazyBlockFrequencyInfoPass::LazyBlockFrequencyInfoPass() : FunctionPass(ID) {
      35       21405 :   initializeLazyBlockFrequencyInfoPassPass(*PassRegistry::getPassRegistry());
      36       21405 : }
      37             : 
      38           5 : void LazyBlockFrequencyInfoPass::print(raw_ostream &OS, const Module *) const {
      39          10 :   LBFI.getCalculated().print(OS);
      40           5 : }
      41             : 
      42       21408 : void LazyBlockFrequencyInfoPass::getAnalysisUsage(AnalysisUsage &AU) const {
      43       21408 :   LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AU);
      44             :   AU.addRequired<LoopInfoWrapperPass>();
      45             :   AU.setPreservesAll();
      46       21408 : }
      47             : 
      48      726922 : void LazyBlockFrequencyInfoPass::releaseMemory() { LBFI.releaseMemory(); }
      49             : 
      50      363505 : bool LazyBlockFrequencyInfoPass::runOnFunction(Function &F) {
      51      363505 :   auto &BPIPass = getAnalysis<LazyBranchProbabilityInfoPass>();
      52      363505 :   LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
      53             :   LBFI.setAnalysis(&F, &BPIPass, &LI);
      54      363505 :   return false;
      55             : }
      56             : 
      57       22701 : void LazyBlockFrequencyInfoPass::getLazyBFIAnalysisUsage(AnalysisUsage &AU) {
      58       22701 :   LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AU);
      59             :   AU.addRequired<LazyBlockFrequencyInfoPass>();
      60             :   AU.addRequired<LoopInfoWrapperPass>();
      61       22701 : }
      62             : 
      63       55295 : void llvm::initializeLazyBFIPassPass(PassRegistry &Registry) {
      64       55295 :   initializeLazyBPIPassPass(Registry);
      65       55295 :   INITIALIZE_PASS_DEPENDENCY(LazyBlockFrequencyInfoPass);
      66       55295 :   INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);
      67       55295 : }

Generated by: LCOV version 1.13