LCOV - code coverage report
Current view: top level - lib/Analysis - LazyBlockFrequencyInfo.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 31 31 100.0 %
Date: 2017-09-14 15:23:50 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       41843 : INITIALIZE_PASS_BEGIN(LazyBlockFrequencyInfoPass, DEBUG_TYPE,
      26             :                       "Lazy Block Frequency Analysis", true, true)
      27       41843 : INITIALIZE_PASS_DEPENDENCY(LazyBPIPass)
      28       41843 : INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
      29      294515 : INITIALIZE_PASS_END(LazyBlockFrequencyInfoPass, DEBUG_TYPE,
      30             :                     "Lazy Block Frequency Analysis", true, true)
      31             : 
      32             : char LazyBlockFrequencyInfoPass::ID = 0;
      33             : 
      34       57827 : LazyBlockFrequencyInfoPass::LazyBlockFrequencyInfoPass() : FunctionPass(ID) {
      35       19275 :   initializeLazyBlockFrequencyInfoPassPass(*PassRegistry::getPassRegistry());
      36       19276 : }
      37             : 
      38           4 : void LazyBlockFrequencyInfoPass::print(raw_ostream &OS, const Module *) const {
      39           8 :   LBFI.getCalculated().print(OS);
      40           4 : }
      41             : 
      42       19279 : void LazyBlockFrequencyInfoPass::getAnalysisUsage(AnalysisUsage &AU) const {
      43       19279 :   LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AU);
      44       19279 :   AU.addRequired<LoopInfoWrapperPass>();
      45       19279 :   AU.setPreservesAll();
      46       19279 : }
      47             : 
      48      734196 : void LazyBlockFrequencyInfoPass::releaseMemory() { LBFI.releaseMemory(); }
      49             : 
      50      367142 : bool LazyBlockFrequencyInfoPass::runOnFunction(Function &F) {
      51      367142 :   auto &BPIPass = getAnalysis<LazyBranchProbabilityInfoPass>();
      52      734284 :   LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
      53      734284 :   LBFI.setAnalysis(&F, &BPIPass, &LI);
      54      367142 :   return false;
      55             : }
      56             : 
      57       20247 : void LazyBlockFrequencyInfoPass::getLazyBFIAnalysisUsage(AnalysisUsage &AU) {
      58       20247 :   LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AU);
      59       20248 :   AU.addRequired<LazyBlockFrequencyInfoPass>();
      60       20248 :   AU.addRequired<LoopInfoWrapperPass>();
      61       20248 : }
      62             : 
      63       41843 : void llvm::initializeLazyBFIPassPass(PassRegistry &Registry) {
      64       41843 :   initializeLazyBPIPassPass(Registry);
      65       41843 :   INITIALIZE_PASS_DEPENDENCY(LazyBlockFrequencyInfoPass);
      66       41843 :   INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);
      67       41843 : }

Generated by: LCOV version 1.13