LLVM  4.0.0
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 DominatorTreeBase<BasicBlock> {
27 
29 };
30 
31 /// \brief Analysis pass which computes a \c PostDominatorTree.
33  : public AnalysisInfoMixin<PostDominatorTreeAnalysis> {
35  static AnalysisKey Key;
36 
37 public:
38  /// \brief Provide the result typedef for this analysis pass.
40 
41  /// \brief Run the analysis pass over a function and produce a post dominator
42  /// tree.
44 };
45 
46 /// \brief Printer pass for the \c PostDominatorTree.
48  : public PassInfoMixin<PostDominatorTreePrinterPass> {
49  raw_ostream &OS;
50 
51 public:
54 };
55 
57  static char ID; // Pass identification, replacement for typeid
59 
62  }
63 
65  const PostDominatorTree &getPostDomTree() const { return DT; }
66 
67  bool runOnFunction(Function &F) override;
68 
69  void getAnalysisUsage(AnalysisUsage &AU) const override {
70  AU.setPreservesAll();
71  }
72 
73  void releaseMemory() override {
74  DT.releaseMemory();
75  }
76 
77  void print(raw_ostream &OS, const Module*) const override;
78 };
79 
80 FunctionPass* createPostDomTree();
81 
82 template <> struct GraphTraits<PostDominatorTree*>
83  : public GraphTraits<DomTreeNode*> {
85  return DT->getRootNode();
86  }
87 
89  if (getEntryNode(N))
90  return df_begin(getEntryNode(N));
91  else
92  return df_end(getEntryNode(N));
93  }
94 
96  return df_end(getEntryNode(N));
97  }
98 };
99 
100 } // End llvm namespace
101 
102 #endif
PostDominatorTree run(Function &F, FunctionAnalysisManager &)
Run the analysis pass over a function and produce a post dominator tree.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
const PostDominatorTree & getPostDomTree() const
PostDominatorTreePrinterPass(raw_ostream &OS)
DomTreeNodeBase< NodeT > * getRootNode()
getRootNode - This returns the entry node for the CFG of the function.
DominatorTreeBase< BasicBlock > Base
static nodes_iterator nodes_end(PostDominatorTree *N)
#define F(x, y, z)
Definition: MD5.cpp:51
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:311
Base class for the actual dominator tree node.
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:59
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:107
LLVM Basic Block Representation.
Definition: BasicBlock.h:51
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:328
void print(raw_ostream &OS, const Module *) const override
print - Print out the internal state of the pass.
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)
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
PostDominatorTree & getPostDomTree()
PostDominatorTree Result
Provide the result typedef for this analysis pass.
Analysis pass which computes a PostDominatorTree.
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...
Basic Alias true
#define N
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:44
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
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:64