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"
21 /// PostDominatorSet Class - Concrete subclass of DominatorSetBase that is used
22 /// to compute the post-dominator set. Because there can be multiple exit nodes
23 /// in an LLVM function, we calculate post dominators with a special null block
24 /// which is the virtual exit node that the real exit nodes all virtually branch
25 /// to. Clients should be prepared to see an entry in the dominator sets with a
28 struct PostDominatorSet : public DominatorSetBase {
29 PostDominatorSet() : DominatorSetBase(true) {}
31 virtual bool runOnFunction(Function &F);
33 /// getAnalysisUsage - This pass does not modify the function at all.
35 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
41 /// ImmediatePostDominators Class - Concrete subclass of ImmediateDominatorsBase
42 /// that is used to compute the immediate post-dominators.
44 struct ImmediatePostDominators : public ImmediateDominatorsBase {
45 ImmediatePostDominators() : ImmediateDominatorsBase(true) {}
47 virtual bool runOnFunction(Function &F) {
48 IDoms.clear(); // Reset from the last time we were run...
49 PostDominatorSet &DS = getAnalysis<PostDominatorSet>();
50 Roots = DS.getRoots();
55 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
57 AU.addRequired<PostDominatorSet>();
60 void calcIDoms(const DominatorSetBase &DS);
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 /// PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is
88 /// used to compute the a post-dominance frontier.
90 struct PostDominanceFrontier : public DominanceFrontierBase {
91 PostDominanceFrontier() : DominanceFrontierBase(true) {}
93 virtual bool runOnFunction(Function &) {
95 PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
96 Roots = DT.getRoots();
97 if (const DominatorTree::Node *Root = DT.getRootNode())
102 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
103 AU.setPreservesAll();
104 AU.addRequired<PostDominatorTree>();
107 // stub - dummy function, just ignore it
111 const DomSetType &calculate(const PostDominatorTree &DT,
112 const DominatorTree::Node *Node);
115 // Make sure that any clients of this file link in PostDominators.cpp
117 POST_DOMINATOR_INCLUDE_FILE((void*)&PostDominanceFrontier::stub);
119 } // End llvm namespace