LLVM  9.0.0svn
PostDominators.h
Go to the documentation of this file.
1 //=- llvm/Analysis/PostDominators.h - Post Dominator Calculation --*- C++ -*-=//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file exposes interfaces to post dominance information.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_ANALYSIS_POSTDOMINATORS_H
14 #define LLVM_ANALYSIS_POSTDOMINATORS_H
15 
17 #include "llvm/IR/Dominators.h"
18 #include "llvm/IR/PassManager.h"
19 #include "llvm/Pass.h"
20 
21 namespace llvm {
22 
23 class Function;
24 class raw_ostream;
25 
26 /// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
27 /// compute the post-dominator tree.
28 class PostDominatorTree : public PostDomTreeBase<BasicBlock> {
29 public:
31 
32  PostDominatorTree() = default;
34  /// Handle invalidation explicitly.
35  bool invalidate(Function &F, const PreservedAnalyses &PA,
37 };
38 
39 /// Analysis pass which computes a \c PostDominatorTree.
41  : public AnalysisInfoMixin<PostDominatorTreeAnalysis> {
43 
44  static AnalysisKey Key;
45 
46 public:
47  /// Provide the result type for this analysis pass.
49 
50  /// Run the analysis pass over a function and produce a post dominator
51  /// tree.
53 };
54 
55 /// Printer pass for the \c PostDominatorTree.
57  : public PassInfoMixin<PostDominatorTreePrinterPass> {
58  raw_ostream &OS;
59 
60 public:
62 
64 };
65 
67  static char ID; // Pass identification, replacement for typeid
68 
70 
73  }
74 
76  const PostDominatorTree &getPostDomTree() const { return DT; }
77 
78  bool runOnFunction(Function &F) override;
79 
80  void verifyAnalysis() const override;
81 
82  void getAnalysisUsage(AnalysisUsage &AU) const override {
83  AU.setPreservesAll();
84  }
85 
86  void releaseMemory() override {
87  DT.releaseMemory();
88  }
89 
90  void print(raw_ostream &OS, const Module*) const override;
91 };
92 
94 
95 template <> struct GraphTraits<PostDominatorTree*>
96  : public GraphTraits<DomTreeNode*> {
98  return DT->getRootNode();
99  }
100 
101  static nodes_iterator nodes_begin(PostDominatorTree *N) {
102  if (getEntryNode(N))
103  return df_begin(getEntryNode(N));
104  else
105  return df_end(getEntryNode(N));
106  }
107 
108  static nodes_iterator nodes_end(PostDominatorTree *N) {
109  return df_end(getEntryNode(N));
110  }
111 };
112 
113 } // end namespace llvm
114 
115 #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:23
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:365
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
static bool runOnFunction(Function &F, bool PostInlining)
typename DomTreeNode *::UnknownGraphTypeError NodeRef
Definition: GraphTraits.h:78
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:284
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:641
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:45
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