/home/runner/work/DirectXShaderCompiler/DirectXShaderCompiler/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/IR/Dominators.h" |
18 | | |
19 | | namespace llvm { |
20 | | |
21 | | /// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to |
22 | | /// compute the post-dominator tree. |
23 | | /// |
24 | | struct PostDominatorTree : public FunctionPass { |
25 | | static char ID; // Pass identification, replacement for typeid |
26 | | DominatorTreeBase<BasicBlock>* DT; |
27 | | |
28 | 39.6k | PostDominatorTree() : FunctionPass(ID) { |
29 | 39.6k | initializePostDominatorTreePass(*PassRegistry::getPassRegistry()); |
30 | 39.6k | DT = new DominatorTreeBase<BasicBlock>(true); |
31 | 39.6k | } |
32 | | |
33 | | ~PostDominatorTree() override; |
34 | | |
35 | | bool runOnFunction(Function &F) override; |
36 | | |
37 | 39.1k | void getAnalysisUsage(AnalysisUsage &AU) const override { |
38 | 39.1k | AU.setPreservesAll(); |
39 | 39.1k | } |
40 | | |
41 | 0 | inline const std::vector<BasicBlock*> &getRoots() const { |
42 | 0 | return DT->getRoots(); |
43 | 0 | } |
44 | | |
45 | 0 | inline DomTreeNode *getRootNode() const { |
46 | 0 | return DT->getRootNode(); |
47 | 0 | } |
48 | | |
49 | 0 | inline DomTreeNode *operator[](BasicBlock *BB) const { |
50 | 0 | return DT->getNode(BB); |
51 | 0 | } |
52 | | |
53 | 0 | inline DomTreeNode *getNode(BasicBlock *BB) const { |
54 | 0 | return DT->getNode(BB); |
55 | 0 | } |
56 | | |
57 | 0 | inline bool dominates(DomTreeNode* A, DomTreeNode* B) const { |
58 | 0 | return DT->dominates(A, B); |
59 | 0 | } |
60 | | |
61 | 15.3k | inline bool dominates(const BasicBlock* A, const BasicBlock* B) const { |
62 | 15.3k | return DT->dominates(A, B); |
63 | 15.3k | } |
64 | | |
65 | 0 | inline bool properlyDominates(const DomTreeNode* A, DomTreeNode* B) const { |
66 | 0 | return DT->properlyDominates(A, B); |
67 | 0 | } |
68 | | |
69 | 23.6k | inline bool properlyDominates(BasicBlock* A, BasicBlock* B) const { |
70 | 23.6k | return DT->properlyDominates(A, B); |
71 | 23.6k | } |
72 | | |
73 | 6.75k | inline BasicBlock *findNearestCommonDominator(BasicBlock *A, BasicBlock *B) { |
74 | 6.75k | return DT->findNearestCommonDominator(A, B); |
75 | 6.75k | } |
76 | | |
77 | | inline const BasicBlock *findNearestCommonDominator(const BasicBlock *A, |
78 | 0 | const BasicBlock *B) { |
79 | 0 | return DT->findNearestCommonDominator(A, B); |
80 | 0 | } |
81 | | |
82 | | /// Get all nodes post-dominated by R, including R itself. |
83 | | void getDescendants(BasicBlock *R, |
84 | 2 | SmallVectorImpl<BasicBlock *> &Result) const { |
85 | 2 | DT->getDescendants(R, Result); |
86 | 2 | } |
87 | | |
88 | 46.0k | void releaseMemory() override { |
89 | 46.0k | DT->releaseMemory(); |
90 | 46.0k | } |
91 | | |
92 | | void print(raw_ostream &OS, const Module*) const override; |
93 | | }; |
94 | | |
95 | | FunctionPass* createPostDomTree(); |
96 | | |
97 | | template <> struct GraphTraits<PostDominatorTree*> |
98 | | : public GraphTraits<DomTreeNode*> { |
99 | 0 | static NodeType *getEntryNode(PostDominatorTree *DT) { |
100 | 0 | return DT->getRootNode(); |
101 | 0 | } |
102 | | |
103 | 0 | static nodes_iterator nodes_begin(PostDominatorTree *N) { |
104 | 0 | if (getEntryNode(N)) |
105 | 0 | return df_begin(getEntryNode(N)); |
106 | 0 | else |
107 | 0 | return df_end(getEntryNode(N)); |
108 | 0 | } |
109 | | |
110 | 0 | static nodes_iterator nodes_end(PostDominatorTree *N) { |
111 | 0 | return df_end(getEntryNode(N)); |
112 | 0 | } |
113 | | }; |
114 | | |
115 | | } // End llvm namespace |
116 | | |
117 | | #endif |