X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FPostDominators.cpp;h=6ed27297923fc1b753d761cefa38d4a6591ee540;hb=657720bc6ed1f214c4e7f45f80dcc15b2e168288;hp=cd29749c830e65c15fc6a6ee669929176264c368;hpb=303f47b1dd3166a8abcd5425f863f7b4815a8e42;p=oota-llvm.git diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index cd29749c830..6ed27297923 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -11,12 +11,16 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "postdomtree" + #include "llvm/Analysis/PostDominators.h" #include "llvm/Instructions.h" #include "llvm/Support/CFG.h" +#include "llvm/Support/Debug.h" #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/SetOperations.h" -#include "PostDominatorCalculation.h" +#include "llvm/Assembly/Writer.h" +#include "llvm/Analysis/DominatorInternals.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -24,52 +28,24 @@ using namespace llvm; //===----------------------------------------------------------------------===// char PostDominatorTree::ID = 0; -char PostDominanceFrontier::ID = 0; -static RegisterPass -F("postdomtree", "Post-Dominator Tree Construction", true); - -//===----------------------------------------------------------------------===// -// PostDominanceFrontier Implementation -//===----------------------------------------------------------------------===// +INITIALIZE_PASS(PostDominatorTree, "postdomtree", + "Post-Dominator Tree Construction", true, true) -static RegisterPass -H("postdomfrontier", "Post-Dominance Frontier Construction", true); - -const DominanceFrontier::DomSetType & -PostDominanceFrontier::calculate(const PostDominatorTree &DT, - const DomTreeNode *Node) { - // Loop over CFG successors to calculate DFlocal[Node] - BasicBlock *BB = Node->getBlock(); - DomSetType &S = Frontiers[BB]; // The new set to fill in... - if (getRoots().empty()) return S; +bool PostDominatorTree::runOnFunction(Function &F) { + DT->recalculate(F); + return false; +} - if (BB) - for (pred_iterator SI = pred_begin(BB), SE = pred_end(BB); - SI != SE; ++SI) { - // Does Node immediately dominate this predecessor? - DomTreeNode *SINode = DT[*SI]; - if (SINode && SINode->getIDom() != Node) - S.insert(*SI); - } +PostDominatorTree::~PostDominatorTree() { + delete DT; +} - // At this point, S is DFlocal. Now we union in DFup's of our children... - // Loop through and visit the nodes that Node immediately dominates (Node's - // children in the IDomTree) - // - for (DomTreeNode::const_iterator - NI = Node->begin(), NE = Node->end(); NI != NE; ++NI) { - DomTreeNode *IDominee = *NI; - const DomSetType &ChildDF = calculate(DT, IDominee); +void PostDominatorTree::print(raw_ostream &OS, const Module *) const { + DT->print(OS); +} - DomSetType::const_iterator CDFI = ChildDF.begin(), CDFE = ChildDF.end(); - for (; CDFI != CDFE; ++CDFI) { - if (!DT.properlyDominates(Node, DT[*CDFI])) - S.insert(*CDFI); - } - } - return S; +FunctionPass* llvm::createPostDomTree() { + return new PostDominatorTree(); } -// Ensure that this .cpp file gets linked when PostDominators.h is used. -DEFINING_FILE_FOR(PostDominanceFrontier)