2003-09-30 20:37:50 +02:00
|
|
|
//=- llvm/Analysis/PostDominators.h - Post Dominator Calculation-*- C++ -*-===//
|
2005-04-21 22:19:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:19:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-08-22 01:43:50 +02:00
|
|
|
//
|
|
|
|
// This file exposes interfaces to post dominance information.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_ANALYSIS_POST_DOMINATORS_H
|
|
|
|
#define LLVM_ANALYSIS_POST_DOMINATORS_H
|
|
|
|
|
2011-04-05 23:57:17 +02:00
|
|
|
#include "llvm/Analysis/Dominators.h"
|
2002-08-22 01:43:50 +02:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2004-03-01 00:55:11 +01:00
|
|
|
/// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
|
|
|
|
/// compute the a post-dominator tree.
|
|
|
|
///
|
2007-10-23 22:58:37 +02:00
|
|
|
struct PostDominatorTree : public FunctionPass {
|
2007-05-06 15:37:16 +02:00
|
|
|
static char ID; // Pass identification, replacement for typeid
|
2007-10-23 22:58:37 +02:00
|
|
|
DominatorTreeBase<BasicBlock>* DT;
|
2007-05-01 23:15:47 +02:00
|
|
|
|
2010-08-06 20:33:48 +02:00
|
|
|
PostDominatorTree() : FunctionPass(ID) {
|
2010-10-19 19:21:58 +02:00
|
|
|
initializePostDominatorTreePass(*PassRegistry::getPassRegistry());
|
2007-10-23 23:42:49 +02:00
|
|
|
DT = new DominatorTreeBase<BasicBlock>(true);
|
2007-10-23 22:58:37 +02:00
|
|
|
}
|
2002-08-22 01:43:50 +02:00
|
|
|
|
2008-05-03 22:25:26 +02:00
|
|
|
~PostDominatorTree();
|
|
|
|
|
2007-10-03 05:20:17 +02:00
|
|
|
virtual bool runOnFunction(Function &F);
|
2002-08-22 01:43:50 +02:00
|
|
|
|
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesAll();
|
|
|
|
}
|
2010-01-11 23:22:46 +01:00
|
|
|
|
2007-10-23 22:58:37 +02:00
|
|
|
inline const std::vector<BasicBlock*> &getRoots() const {
|
|
|
|
return DT->getRoots();
|
|
|
|
}
|
2010-01-11 23:22:46 +01:00
|
|
|
|
2007-10-23 22:58:37 +02:00
|
|
|
inline DomTreeNode *getRootNode() const {
|
|
|
|
return DT->getRootNode();
|
|
|
|
}
|
2010-01-11 23:22:46 +01:00
|
|
|
|
2007-10-23 22:58:37 +02:00
|
|
|
inline DomTreeNode *operator[](BasicBlock *BB) const {
|
|
|
|
return DT->getNode(BB);
|
|
|
|
}
|
2010-01-11 23:22:46 +01:00
|
|
|
|
2010-01-11 23:22:32 +01:00
|
|
|
inline DomTreeNode *getNode(BasicBlock *BB) const {
|
|
|
|
return DT->getNode(BB);
|
|
|
|
}
|
|
|
|
|
2009-09-27 19:39:12 +02:00
|
|
|
inline bool dominates(DomTreeNode* A, DomTreeNode* B) const {
|
|
|
|
return DT->dominates(A, B);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool dominates(const BasicBlock* A, const BasicBlock* B) const {
|
|
|
|
return DT->dominates(A, B);
|
|
|
|
}
|
|
|
|
|
2007-10-23 22:58:37 +02:00
|
|
|
inline bool properlyDominates(const DomTreeNode* A, DomTreeNode* B) const {
|
|
|
|
return DT->properlyDominates(A, B);
|
|
|
|
}
|
2010-01-11 23:22:46 +01:00
|
|
|
|
2007-10-23 22:58:37 +02:00
|
|
|
inline bool properlyDominates(BasicBlock* A, BasicBlock* B) const {
|
|
|
|
return DT->properlyDominates(A, B);
|
|
|
|
}
|
2008-02-27 19:38:29 +01:00
|
|
|
|
2010-03-07 12:15:04 +01:00
|
|
|
inline BasicBlock *findNearestCommonDominator(BasicBlock *A, BasicBlock *B) {
|
|
|
|
return DT->findNearestCommonDominator(A, B);
|
|
|
|
}
|
|
|
|
|
2009-09-27 19:39:12 +02:00
|
|
|
virtual void releaseMemory() {
|
|
|
|
DT->releaseMemory();
|
|
|
|
}
|
|
|
|
|
2009-08-23 08:03:38 +02:00
|
|
|
virtual void print(raw_ostream &OS, const Module*) const;
|
2002-08-22 01:43:50 +02:00
|
|
|
};
|
|
|
|
|
2008-05-29 19:00:13 +02:00
|
|
|
FunctionPass* createPostDomTree();
|
2002-08-22 01:43:50 +02:00
|
|
|
|
2009-10-18 06:05:53 +02:00
|
|
|
template <> struct GraphTraits<PostDominatorTree*>
|
|
|
|
: public GraphTraits<DomTreeNode*> {
|
|
|
|
static NodeType *getEntryNode(PostDominatorTree *DT) {
|
|
|
|
return DT->getRootNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
static nodes_iterator nodes_begin(PostDominatorTree *N) {
|
2009-11-30 13:06:37 +01:00
|
|
|
if (getEntryNode(N))
|
|
|
|
return df_begin(getEntryNode(N));
|
|
|
|
else
|
|
|
|
return df_end(getEntryNode(N));
|
2009-10-18 06:05:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nodes_iterator nodes_end(PostDominatorTree *N) {
|
|
|
|
return df_end(getEntryNode(N));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2002-08-22 01:43:50 +02:00
|
|
|
#endif
|