Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Analysis/DominanceFrontier.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- DominanceFrontier.cpp - Dominance Frontier Calculation -------------===//
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
#include "llvm/Analysis/DominanceFrontier.h"
10
#include "llvm/Analysis/DominanceFrontierImpl.h"
11
#include "llvm/Config/llvm-config.h"
12
#include "llvm/IR/Dominators.h"
13
#include "llvm/IR/Function.h"
14
#include "llvm/IR/PassManager.h"
15
#include "llvm/Pass.h"
16
#include "llvm/Support/Compiler.h"
17
#include "llvm/Support/Debug.h"
18
#include "llvm/Support/raw_ostream.h"
19
20
using namespace llvm;
21
22
namespace llvm {
23
24
template class DominanceFrontierBase<BasicBlock, false>;
25
template class DominanceFrontierBase<BasicBlock, true>;
26
template class ForwardDominanceFrontierBase<BasicBlock>;
27
28
} // end namespace llvm
29
30
char DominanceFrontierWrapperPass::ID = 0;
31
32
73.2k
INITIALIZE_PASS_BEGIN(DominanceFrontierWrapperPass, "domfrontier",
33
73.2k
                "Dominance Frontier Construction", true, true)
34
73.2k
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
35
73.2k
INITIALIZE_PASS_END(DominanceFrontierWrapperPass, "domfrontier",
36
                "Dominance Frontier Construction", true, true)
37
38
DominanceFrontierWrapperPass::DominanceFrontierWrapperPass()
39
4.03k
    : FunctionPass(ID), DF() {
40
4.03k
  initializeDominanceFrontierWrapperPassPass(*PassRegistry::getPassRegistry());
41
4.03k
}
42
43
58.0k
void DominanceFrontierWrapperPass::releaseMemory() {
44
58.0k
  DF.releaseMemory();
45
58.0k
}
46
47
29.0k
bool DominanceFrontierWrapperPass::runOnFunction(Function &) {
48
29.0k
  releaseMemory();
49
29.0k
  DF.analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree());
50
29.0k
  return false;
51
29.0k
}
52
53
4.03k
void DominanceFrontierWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
54
4.03k
  AU.setPreservesAll();
55
4.03k
  AU.addRequired<DominatorTreeWrapperPass>();
56
4.03k
}
57
58
2
void DominanceFrontierWrapperPass::print(raw_ostream &OS, const Module *) const {
59
2
  DF.print(OS);
60
2
}
61
62
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
63
LLVM_DUMP_METHOD void DominanceFrontierWrapperPass::dump() const {
64
  print(dbgs());
65
}
66
#endif
67
68
/// Handle invalidation explicitly.
69
bool DominanceFrontier::invalidate(Function &F, const PreservedAnalyses &PA,
70
21
                                   FunctionAnalysisManager::Invalidator &) {
71
21
  // Check whether the analysis, all analyses on functions, or the function's
72
21
  // CFG have been preserved.
73
21
  auto PAC = PA.getChecker<DominanceFrontierAnalysis>();
74
21
  return !(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Function>>() ||
75
21
           PAC.preservedSet<CFGAnalyses>());
76
21
}
77
78
AnalysisKey DominanceFrontierAnalysis::Key;
79
80
DominanceFrontier DominanceFrontierAnalysis::run(Function &F,
81
29
                                                 FunctionAnalysisManager &AM) {
82
29
  DominanceFrontier DF;
83
29
  DF.analyze(AM.getResult<DominatorTreeAnalysis>(F));
84
29
  return DF;
85
29
}
86
87
DominanceFrontierPrinterPass::DominanceFrontierPrinterPass(raw_ostream &OS)
88
0
  : OS(OS) {}
89
90
PreservedAnalyses
91
0
DominanceFrontierPrinterPass::run(Function &F, FunctionAnalysisManager &AM) {
92
0
  OS << "DominanceFrontier for function: " << F.getName() << "\n";
93
0
  AM.getResult<DominanceFrontierAnalysis>(F).print(OS);
94
0
95
0
  return PreservedAnalyses::all();
96
0
}