1 //=- llvm/Analysis/PostDominators.h - Post Dominator Calculation-*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file exposes interfaces to post dominance information.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ANALYSIS_POST_DOMINATORS_H
15 #define LLVM_ANALYSIS_POST_DOMINATORS_H
17 #include "llvm/Analysis/Dominators.h"
22 /// PostDominatorSet Class - Concrete subclass of DominatorSetBase that is used
23 /// to compute the post-dominator set. Because there can be multiple exit nodes
24 /// in an LLVM function, we calculate post dominators with a special null block
25 /// which is the virtual exit node that the real exit nodes all virtually branch
26 /// to. Clients should be prepared to see an entry in the dominator sets with a
29 struct PostDominatorSet : public DominatorSetBase {
30 PostDominatorSet() : DominatorSetBase(true) {}
32 virtual bool runOnFunction(Function &F);
34 // getAnalysisUsage - This pass does not modify the function at all.
36 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
43 //===-------------------------------------
44 // ImmediatePostDominators Class - Concrete subclass of ImmediateDominatorsBase
45 // that is used to compute the immediate post-dominators.
47 struct ImmediatePostDominators : public ImmediateDominatorsBase {
48 ImmediatePostDominators() : ImmediateDominatorsBase(true) {}
50 virtual bool runOnFunction(Function &F) {
51 IDoms.clear(); // Reset from the last time we were run...
52 PostDominatorSet &DS = getAnalysis<PostDominatorSet>();
53 Roots = DS.getRoots();
58 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
60 AU.addRequired<PostDominatorSet>();
63 void calcIDoms(const DominatorSetBase &DS);
67 //===-------------------------------------
68 // PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
69 // compute the a post-dominator tree.
71 struct PostDominatorTree : public DominatorTreeBase {
72 PostDominatorTree() : DominatorTreeBase(true) {}
74 virtual bool runOnFunction(Function &F) {
75 reset(); // Reset from the last time we were run...
76 PostDominatorSet &DS = getAnalysis<PostDominatorSet>();
77 Roots = DS.getRoots();
82 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
84 AU.addRequired<PostDominatorSet>();
87 void calculate(const PostDominatorSet &DS);
91 //===-------------------------------------
92 // PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is
93 // used to compute the a post-dominance frontier.
95 struct PostDominanceFrontier : public DominanceFrontierBase {
96 PostDominanceFrontier() : DominanceFrontierBase(true) {}
98 virtual bool runOnFunction(Function &) {
100 PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
101 Roots = DT.getRoots();
102 if (const DominatorTree::Node *Root = DT.getRootNode())
107 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
108 AU.setPreservesAll();
109 AU.addRequired<PostDominatorTree>();
112 // stub - dummy function, just ignore it
116 const DomSetType &calculate(const PostDominatorTree &DT,
117 const DominatorTree::Node *Node);
120 // Make sure that any clients of this file link in PostDominators.cpp
122 POST_DOMINATOR_INCLUDE_FILE((void*)&PostDominanceFrontier::stub);
124 } // End llvm namespace