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>();
65 //===-------------------------------------
66 // PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
67 // compute the a post-dominator tree.
69 struct PostDominatorTree : public DominatorTreeBase {
70 PostDominatorTree() : DominatorTreeBase(true) {}
72 virtual bool runOnFunction(Function &F) {
73 reset(); // Reset from the last time we were run...
74 PostDominatorSet &DS = getAnalysis<PostDominatorSet>();
75 Roots = DS.getRoots();
80 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
82 AU.addRequired<PostDominatorSet>();
85 void calculate(const PostDominatorSet &DS);
89 //===-------------------------------------
90 // PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is
91 // used to compute the a post-dominance frontier.
93 struct PostDominanceFrontier : public DominanceFrontierBase {
94 PostDominanceFrontier() : DominanceFrontierBase(true) {}
96 virtual bool runOnFunction(Function &) {
98 PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
99 Roots = DT.getRoots();
100 if (const DominatorTree::Node *Root = DT.getRootNode())
105 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
106 AU.setPreservesAll();
107 AU.addRequired<PostDominatorTree>();
110 // stub - dummy function, just ignore it
114 const DomSetType &calculate(const PostDominatorTree &DT,
115 const DominatorTree::Node *Node);
118 // Make sure that any clients of this file link in PostDominators.cpp
120 POST_DOMINATOR_INCLUDE_FILE((void*)&PostDominanceFrontier::stub);
122 } // End llvm namespace