LLVM  8.0.1
PostDominators.h
Go to the documentation of this file.
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 
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:
32 
33  PostDominatorTree() = default;
35  /// Handle invalidation explicitly.
36  bool invalidate(Function &F, const PreservedAnalyses &PA,
38 };
39 
40 /// Analysis pass which computes a \c PostDominatorTree.
42  : public AnalysisInfoMixin<PostDominatorTreeAnalysis> {
44 
45  static AnalysisKey Key;
46 
47 public:
48  /// Provide the result type for this analysis pass.
50 
51  /// Run the analysis pass over a function and produce a post dominator
52  /// tree.
54 };
55 
56 /// Printer pass for the \c PostDominatorTree.
58  : public PassInfoMixin<PostDominatorTreePrinterPass> {
59  raw_ostream &OS;
60 
61 public:
63 
65 };
66 
68  static char ID; // Pass identification, replacement for typeid
69 
71 
74  }
75 
77  const PostDominatorTree &getPostDomTree() const { return DT; }
78 
79  bool runOnFunction(Function &F) override;
80 
81  void verifyAnalysis() const override;
82 
83  void getAnalysisUsage(AnalysisUsage &AU) const override {
84  AU.setPreservesAll();
85  }
86 
87  void releaseMemory() override {
88  DT.releaseMemory();
89  }
90 
91  void print(raw_ostream &OS, const Module*) const override;
92 };
93 
95 
96 template <> struct GraphTraits<PostDominatorTree*>
97  : public GraphTraits<DomTreeNode*> {
99  return DT->getRootNode();
100  }
101 
102  static nodes_iterator nodes_begin(PostDominatorTree *N) {
103  if (getEntryNode(N))
104  return df_begin(getEntryNode(N));
105  else
106  return df_end(getEntryNode(N));
107  }
108 
109  static nodes_iterator nodes_end(PostDominatorTree *N) {
110  return df_end(getEntryNode(N));
111  }
112 };
113 
114 } // end namespace llvm
115 
116 #endif // LLVM_ANALYSIS_POSTDOMINATORS_H
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
This class represents lattice values for constants.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
void recalculate(ParentType &Func)
recalculate - compute a dominator tree for the given function
F(f)
Key
PAL metadata keys.
static nodes_iterator nodes_end(PostDominatorTree *N)
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:366
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Core dominator tree base class.
Definition: LoopInfo.h:61
static bool runOnFunction(Function &F, bool PostInlining)
typename DomTreeNode *::UnknownGraphTypeError NodeRef
Definition: GraphTraits.h:79
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:154
void initializePostDominatorTreeWrapperPassPass(PassRegistry &)
df_iterator< T > df_end(const T &G)
static nodes_iterator nodes_begin(PostDominatorTree *N)
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:383
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:285
static NodeRef getEntryNode(PostDominatorTree *DT)
DomTreeNodeBase< NodeT > * getRootNode()
getRootNode - This returns the entry node for the CFG of the function.
void print(raw_ostream &O) const
print - Convert to human readable form
PostDominatorTree & getPostDomTree()
Analysis pass which computes a PostDominatorTree.
PostDominatorTree(Function &F)
df_iterator< T > df_begin(const T &G)
void setPreservesAll()
Set by analyses that do not transform their input at all.
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
const PostDominatorTree & getPostDomTree() const
#define N
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:642
Printer pass for the PostDominatorTree.
FunctionPass * createPostDomTree()
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:71