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-05-20 00:06:23 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             : #include "llvm/IR/Dominators.h"
      21             : 
      22             : using namespace llvm;
      23             : 
      24             : #define DEBUG_TYPE "lazy-block-freq"
      25             : 
      26       55922 : INITIALIZE_PASS_BEGIN(LazyBlockFrequencyInfoPass, DEBUG_TYPE,
      27             :                       "Lazy Block Frequency Analysis", true, true)
      28       55922 : INITIALIZE_PASS_DEPENDENCY(LazyBPIPass)
      29       55922 : INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
      30      288952 : INITIALIZE_PASS_END(LazyBlockFrequencyInfoPass, DEBUG_TYPE,
      31             :                     "Lazy Block Frequency Analysis", true, true)
      32             : 
      33             : char LazyBlockFrequencyInfoPass::ID = 0;
      34             : 
      35       44928 : LazyBlockFrequencyInfoPass::LazyBlockFrequencyInfoPass() : FunctionPass(ID) {
      36       22464 :   initializeLazyBlockFrequencyInfoPassPass(*PassRegistry::getPassRegistry());
      37       22464 : }
      38             : 
      39           5 : void LazyBlockFrequencyInfoPass::print(raw_ostream &OS, const Module *) const {
      40          10 :   LBFI.getCalculated().print(OS);
      41           5 : }
      42             : 
      43       22467 : void LazyBlockFrequencyInfoPass::getAnalysisUsage(AnalysisUsage &AU) const {
      44       22467 :   LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AU);
      45             :   // We require DT so it's available when LI is available. The LI updating code
      46             :   // asserts that DT is also present so if we don't make sure that we have DT
      47             :   // here, that assert will trigger.
      48             :   AU.addRequired<DominatorTreeWrapperPass>();
      49             :   AU.addRequired<LoopInfoWrapperPass>();
      50             :   AU.setPreservesAll();
      51       22467 : }
      52             : 
      53      739756 : void LazyBlockFrequencyInfoPass::releaseMemory() { LBFI.releaseMemory(); }
      54             : 
      55      369922 : bool LazyBlockFrequencyInfoPass::runOnFunction(Function &F) {
      56      369922 :   auto &BPIPass = getAnalysis<LazyBranchProbabilityInfoPass>();
      57      369922 :   LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
      58             :   LBFI.setAnalysis(&F, &BPIPass, &LI);
      59      369922 :   return false;
      60             : }
      61             : 
      62       23859 : void LazyBlockFrequencyInfoPass::getLazyBFIAnalysisUsage(AnalysisUsage &AU) {
      63       23859 :   LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AU);
      64             :   AU.addRequired<LazyBlockFrequencyInfoPass>();
      65             :   AU.addRequired<LoopInfoWrapperPass>();
      66       23859 : }
      67             : 
      68       55922 : void llvm::initializeLazyBFIPassPass(PassRegistry &Registry) {
      69       55922 :   initializeLazyBPIPassPass(Registry);
      70       55922 :   INITIALIZE_PASS_DEPENDENCY(LazyBlockFrequencyInfoPass);
      71       55922 :   INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);
      72       55922 : }

Generated by: LCOV version 1.13