1 //=- llvm/Analysis/PostDominators.h - Post Dominator Calculation -*- C++ -*--=//
3 // This file exposes interfaces to post dominance information.
5 //===----------------------------------------------------------------------===//
7 #ifndef LLVM_ANALYSIS_POST_DOMINATORS_H
8 #define LLVM_ANALYSIS_POST_DOMINATORS_H
10 #include "llvm/Analysis/Dominators.h"
13 /// PostDominatorSet Class - Concrete subclass of DominatorSetBase that is used
14 /// to compute the post-dominator set. Because there can be multiple exit nodes
15 /// in an LLVM function, we calculate post dominators with a special null block
16 /// which is the virtual exit node that the real exit nodes all virtually branch
17 /// to. Clients should be prepared to see an entry in the dominator sets with a
20 struct PostDominatorSet : public DominatorSetBase {
21 PostDominatorSet() : DominatorSetBase(true) {}
23 virtual bool runOnFunction(Function &F);
25 // getAnalysisUsage - This pass does not modify the function at all.
27 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
34 //===-------------------------------------
35 // ImmediatePostDominators Class - Concrete subclass of ImmediateDominatorsBase
36 // that is used to compute the immediate post-dominators.
38 struct ImmediatePostDominators : public ImmediateDominatorsBase {
39 ImmediatePostDominators() : ImmediateDominatorsBase(true) {}
41 virtual bool runOnFunction(Function &F) {
42 IDoms.clear(); // Reset from the last time we were run...
43 PostDominatorSet &DS = getAnalysis<PostDominatorSet>();
44 Roots = DS.getRoots();
49 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
51 AU.addRequired<PostDominatorSet>();
56 //===-------------------------------------
57 // PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
58 // compute the a post-dominator tree.
60 struct PostDominatorTree : public DominatorTreeBase {
61 PostDominatorTree() : DominatorTreeBase(true) {}
63 virtual bool runOnFunction(Function &F) {
64 reset(); // Reset from the last time we were run...
65 PostDominatorSet &DS = getAnalysis<PostDominatorSet>();
66 Roots = DS.getRoots();
71 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
73 AU.addRequired<PostDominatorSet>();
76 void calculate(const PostDominatorSet &DS);
80 //===-------------------------------------
81 // PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is
82 // used to compute the a post-dominance frontier.
84 struct PostDominanceFrontier : public DominanceFrontierBase {
85 PostDominanceFrontier() : DominanceFrontierBase(true) {}
87 virtual bool runOnFunction(Function &) {
89 PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
90 Roots = DT.getRoots();
91 if (const DominatorTree::Node *Root = DT.getRootNode())
96 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
98 AU.addRequired<PostDominatorTree>();
101 // stub - dummy function, just ignore it
105 const DomSetType &calculate(const PostDominatorTree &DT,
106 const DominatorTree::Node *Node);
109 // Make sure that any clients of this file link in PostDominators.cpp
111 POST_DOMINATOR_INCLUDE_FILE((void*)&PostDominanceFrontier::stub);