Coverage Report

Created: 2018-09-19 08:35

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Analysis/PostDominators.h
Line
Count
Source (jump to first uncovered line)
1
//=- llvm/Analysis/PostDominators.h - Post Dominator Calculation --*- C++ -*-=//
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 file exposes interfaces to post dominance information.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_ANALYSIS_POSTDOMINATORS_H
15
#define LLVM_ANALYSIS_POSTDOMINATORS_H
16
17
#include "llvm/ADT/DepthFirstIterator.h"
18
#include "llvm/IR/Dominators.h"
19
#include "llvm/IR/PassManager.h"
20
#include "llvm/Pass.h"
21
22
namespace llvm {
23
24
class Function;
25
class raw_ostream;
26
27
/// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
28
/// compute the post-dominator tree.
29
class PostDominatorTree : public PostDomTreeBase<BasicBlock> {
30
public:
31
  using Base = PostDomTreeBase<BasicBlock>;
32
33
38.3k
  PostDominatorTree() = default;
34
405
  explicit PostDominatorTree(Function &F) { recalculate(F); }
35
  /// Handle invalidation explicitly.
36
  bool invalidate(Function &F, const PreservedAnalyses &PA,
37
                  FunctionAnalysisManager::Invalidator &);
38
};
39
40
/// Analysis pass which computes a \c PostDominatorTree.
41
class PostDominatorTreeAnalysis
42
    : public AnalysisInfoMixin<PostDominatorTreeAnalysis> {
43
  friend AnalysisInfoMixin<PostDominatorTreeAnalysis>;
44
45
  static AnalysisKey Key;
46
47
public:
48
  /// Provide the result type for this analysis pass.
49
  using Result = PostDominatorTree;
50
51
  /// Run the analysis pass over a function and produce a post dominator
52
  ///        tree.
53
  PostDominatorTree run(Function &F, FunctionAnalysisManager &);
54
};
55
56
/// Printer pass for the \c PostDominatorTree.
57
class PostDominatorTreePrinterPass
58
    : public PassInfoMixin<PostDominatorTreePrinterPass> {
59
  raw_ostream &OS;
60
61
public:
62
  explicit PostDominatorTreePrinterPass(raw_ostream &OS);
63
64
  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
65
};
66
67
struct PostDominatorTreeWrapperPass : public FunctionPass {
68
  static char ID; // Pass identification, replacement for typeid
69
70
  PostDominatorTree DT;
71
72
38.3k
  PostDominatorTreeWrapperPass() : FunctionPass(ID) {
73
38.3k
    initializePostDominatorTreeWrapperPassPass(*PassRegistry::getPassRegistry());
74
38.3k
  }
75
76
1.05M
  PostDominatorTree &getPostDomTree() { return DT; }
77
0
  const PostDominatorTree &getPostDomTree() const { return DT; }
78
79
  bool runOnFunction(Function &F) override;
80
81
  void verifyAnalysis() const override;
82
83
38.3k
  void getAnalysisUsage(AnalysisUsage &AU) const override {
84
38.3k
    AU.setPreservesAll();
85
38.3k
  }
86
87
1.01M
  void releaseMemory() override {
88
1.01M
    DT.releaseMemory();
89
1.01M
  }
90
91
  void print(raw_ostream &OS, const Module*) const override;
92
};
93
94
FunctionPass* createPostDomTree();
95
96
template <> struct GraphTraits<PostDominatorTree*>
97
  : public GraphTraits<DomTreeNode*> {
98
0
  static NodeRef getEntryNode(PostDominatorTree *DT) {
99
0
    return DT->getRootNode();
100
0
  }
101
102
0
  static nodes_iterator nodes_begin(PostDominatorTree *N) {
103
0
    if (getEntryNode(N))
104
0
      return df_begin(getEntryNode(N));
105
0
    else
106
0
      return df_end(getEntryNode(N));
107
0
  }
108
109
0
  static nodes_iterator nodes_end(PostDominatorTree *N) {
110
0
    return df_end(getEntryNode(N));
111
0
  }
112
};
113
114
} // end namespace llvm
115
116
#endif // LLVM_ANALYSIS_POSTDOMINATORS_H