Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Analysis/LazyBlockFrequencyInfo.cpp
Line
Count
Source
1
//===- LazyBlockFrequencyInfo.cpp - Lazy Block Frequency Analysis ---------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This is an alternative analysis pass to BlockFrequencyInfoWrapperPass.  The
10
// difference is that with this pass the block frequencies are not computed when
11
// the analysis pass is executed but rather when the BFI result is explicitly
12
// requested by the analysis client.
13
//
14
//===----------------------------------------------------------------------===//
15
16
#include "llvm/Analysis/LazyBlockFrequencyInfo.h"
17
#include "llvm/Analysis/LazyBranchProbabilityInfo.h"
18
#include "llvm/Analysis/LoopInfo.h"
19
#include "llvm/IR/Dominators.h"
20
21
using namespace llvm;
22
23
#define DEBUG_TYPE "lazy-block-freq"
24
25
73.7k
INITIALIZE_PASS_BEGIN(LazyBlockFrequencyInfoPass, DEBUG_TYPE,
26
73.7k
                      "Lazy Block Frequency Analysis", true, true)
27
73.7k
INITIALIZE_PASS_DEPENDENCY(LazyBPIPass)
28
73.7k
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
29
73.7k
INITIALIZE_PASS_END(LazyBlockFrequencyInfoPass, DEBUG_TYPE,
30
                    "Lazy Block Frequency Analysis", true, true)
31
32
char LazyBlockFrequencyInfoPass::ID = 0;
33
34
220k
LazyBlockFrequencyInfoPass::LazyBlockFrequencyInfoPass() : FunctionPass(ID) {
35
220k
  initializeLazyBlockFrequencyInfoPassPass(*PassRegistry::getPassRegistry());
36
220k
}
37
38
5
void LazyBlockFrequencyInfoPass::print(raw_ostream &OS, const Module *) const {
39
5
  LBFI.getCalculated().print(OS);
40
5
}
41
42
220k
void LazyBlockFrequencyInfoPass::getAnalysisUsage(AnalysisUsage &AU) const {
43
220k
  LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AU);
44
220k
  // We require DT so it's available when LI is available. The LI updating code
45
220k
  // asserts that DT is also present so if we don't make sure that we have DT
46
220k
  // here, that assert will trigger.
47
220k
  AU.addRequired<DominatorTreeWrapperPass>();
48
220k
  AU.addRequired<LoopInfoWrapperPass>();
49
220k
  AU.setPreservesAll();
50
220k
}
51
52
6.22M
void LazyBlockFrequencyInfoPass::releaseMemory() { LBFI.releaseMemory(); }
53
54
6.22M
bool LazyBlockFrequencyInfoPass::runOnFunction(Function &F) {
55
6.22M
  auto &BPIPass = getAnalysis<LazyBranchProbabilityInfoPass>();
56
6.22M
  LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
57
6.22M
  LBFI.setAnalysis(&F, &BPIPass, &LI);
58
6.22M
  return false;
59
6.22M
}
60
61
342k
void LazyBlockFrequencyInfoPass::getLazyBFIAnalysisUsage(AnalysisUsage &AU) {
62
342k
  LazyBranchProbabilityInfoPass::getLazyBPIAnalysisUsage(AU);
63
342k
  AU.addRequired<LazyBlockFrequencyInfoPass>();
64
342k
  AU.addRequired<LoopInfoWrapperPass>();
65
342k
}
66
67
73.7k
void llvm::initializeLazyBFIPassPass(PassRegistry &Registry) {
68
73.7k
  initializeLazyBPIPassPass(Registry);
69
73.7k
  INITIALIZE_PASS_DEPENDENCY(LazyBlockFrequencyInfoPass);
70
73.7k
  INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);
71
73.7k
}