LLVM  6.0.0svn
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 
17 #include "llvm/IR/Dominators.h"
18 #include "llvm/IR/PassManager.h"
19 
20 namespace llvm {
21 
22 /// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
23 /// compute the post-dominator tree.
24 ///
25 struct PostDominatorTree : public PostDomTreeBase<BasicBlock> {
27 
28  /// Handle invalidation explicitly.
29  bool invalidate(Function &F, const PreservedAnalyses &PA,
31 };
32 
33 /// \brief Analysis pass which computes a \c PostDominatorTree.
35  : public AnalysisInfoMixin<PostDominatorTreeAnalysis> {
37  static AnalysisKey Key;
38 
39 public:
40  /// \brief Provide the result typedef for this analysis pass.
42 
43  /// \brief Run the analysis pass over a function and produce a post dominator
44  /// tree.
46 };
47 
48 /// \brief Printer pass for the \c PostDominatorTree.
50  : public PassInfoMixin<PostDominatorTreePrinterPass> {
51  raw_ostream &OS;
52 
53 public:
56 };
57 
59  static char ID; // Pass identification, replacement for typeid
61 
64  }
65 
67  const PostDominatorTree &getPostDomTree() const { return DT; }
68 
69  bool runOnFunction(Function &F) override;
70 
71  void getAnalysisUsage(AnalysisUsage &AU) const override {
72  AU.setPreservesAll();
73  }
74 
75  void releaseMemory() override {
76  DT.releaseMemory();
77  }
78 
79  void print(raw_ostream &OS, const Module*) const override;
80 };
81 
83 
84 template <> struct GraphTraits<PostDominatorTree*>
85  : public GraphTraits<DomTreeNode*> {
87  return DT->getRootNode();
88  }
89 
90  static nodes_iterator nodes_begin(PostDominatorTree *N) {
91  if (getEntryNode(N))
92  return df_begin(getEntryNode(N));
93  else
94  return df_end(getEntryNode(N));
95  }
96 
97  static nodes_iterator nodes_end(PostDominatorTree *N) {
98  return df_end(getEntryNode(N));
99  }
100 };
101 
102 } // End llvm namespace
103 
104 #endif
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
static nodes_iterator nodes_end(PostDominatorTree *N)
#define F(x, y, z)
Definition: MD5.cpp:55
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:365
PostDomTreeBase< BasicBlock > Base
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:60
typename DomTreeNode *::UnknownGraphTypeError NodeRef
Definition: GraphTraits.h:59
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:153
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:382
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
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()
PostDominatorTree Result
Provide the result typedef for this analysis pass.
Analysis pass which computes a PostDominatorTree.
const size_t N
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
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:559
Printer pass for the PostDominatorTree.
FunctionPass * createPostDomTree()
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
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:44
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:70