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"
20 /// PostDominatorSet Class - Concrete subclass of DominatorSetBase that is used
21 /// to compute the post-dominator set. Because there can be multiple exit nodes
22 /// in an LLVM function, we calculate post dominators with a special null block
23 /// which is the virtual exit node that the real exit nodes all virtually branch
24 /// to. Clients should be prepared to see an entry in the dominator sets with a
27 struct PostDominatorSet : public DominatorSetBase {
28 PostDominatorSet() : DominatorSetBase(true) {}
30 virtual bool runOnFunction(Function &F);
32 // getAnalysisUsage - This pass does not modify the function at all.
34 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
41 //===-------------------------------------
42 // ImmediatePostDominators Class - Concrete subclass of ImmediateDominatorsBase
43 // that is used to compute the immediate post-dominators.
45 struct ImmediatePostDominators : public ImmediateDominatorsBase {
46 ImmediatePostDominators() : ImmediateDominatorsBase(true) {}
48 virtual bool runOnFunction(Function &F) {
49 IDoms.clear(); // Reset from the last time we were run...
50 PostDominatorSet &DS = getAnalysis<PostDominatorSet>();
51 Roots = DS.getRoots();
56 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
58 AU.addRequired<PostDominatorSet>();
63 //===-------------------------------------
64 // PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
65 // compute the a post-dominator tree.
67 struct PostDominatorTree : public DominatorTreeBase {
68 PostDominatorTree() : DominatorTreeBase(true) {}
70 virtual bool runOnFunction(Function &F) {
71 reset(); // Reset from the last time we were run...
72 PostDominatorSet &DS = getAnalysis<PostDominatorSet>();
73 Roots = DS.getRoots();
78 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
80 AU.addRequired<PostDominatorSet>();
83 void calculate(const PostDominatorSet &DS);
87 //===-------------------------------------
88 // PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is
89 // used to compute the a post-dominance frontier.
91 struct PostDominanceFrontier : public DominanceFrontierBase {
92 PostDominanceFrontier() : DominanceFrontierBase(true) {}
94 virtual bool runOnFunction(Function &) {
96 PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
97 Roots = DT.getRoots();
98 if (const DominatorTree::Node *Root = DT.getRootNode())
103 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
104 AU.setPreservesAll();
105 AU.addRequired<PostDominatorTree>();
108 // stub - dummy function, just ignore it
112 const DomSetType &calculate(const PostDominatorTree &DT,
113 const DominatorTree::Node *Node);
116 // Make sure that any clients of this file link in PostDominators.cpp
118 POST_DOMINATOR_INCLUDE_FILE((void*)&PostDominanceFrontier::stub);