diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp index 65814a2d0d3..5fdb885e2f6 100644 --- a/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -69,10 +69,7 @@ namespace { bool handleEndBlock(BasicBlock &BB); void RemoveAccessedObjects(const AliasAnalysis::Location &LoadedLoc, SmallPtrSet &DeadStackObjects); - - // getAnalysisUsage - We require post dominance frontiers (aka Control - // Dependence Graph) virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); AU.addRequired(); diff --git a/lib/Transforms/Scalar/LoopDeletion.cpp b/lib/Transforms/Scalar/LoopDeletion.cpp index b60f0c38bbc..6d1d344a929 100644 --- a/lib/Transforms/Scalar/LoopDeletion.cpp +++ b/lib/Transforms/Scalar/LoopDeletion.cpp @@ -17,7 +17,7 @@ #define DEBUG_TYPE "loop-delete" #include "llvm/Transforms/Scalar.h" #include "llvm/Analysis/LoopPass.h" -#include "llvm/Analysis/DominanceFrontier.h" +#include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/SmallVector.h" @@ -52,7 +52,6 @@ namespace { AU.addPreserved(); AU.addPreservedID(LoopSimplifyID); AU.addPreservedID(LCSSAID); - AU.addPreserved(); } }; } @@ -193,7 +192,6 @@ bool LoopDeletion::runOnLoop(Loop* L, LPPassManager& LPM) { // Update the dominator tree and remove the instructions and blocks that will // be deleted from the reference counting scheme. DominatorTree& DT = getAnalysis(); - DominanceFrontier* DF = getAnalysisIfAvailable(); SmallVector ChildNodes; for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); LI != LE; ++LI) { @@ -203,12 +201,10 @@ bool LoopDeletion::runOnLoop(Loop* L, LPPassManager& LPM) { for (SmallVector::iterator DI = ChildNodes.begin(), DE = ChildNodes.end(); DI != DE; ++DI) { DT.changeImmediateDominator(*DI, DT[preheader]); - if (DF) DF->changeImmediateDominator((*DI)->getBlock(), preheader, &DT); } ChildNodes.clear(); DT.eraseNode(*LI); - if (DF) DF->removeBlock(*LI); // Remove the block from the reference counting scheme, so that we can // delete it freely later. diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 592b18629df..d431b6815c4 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -3814,7 +3814,6 @@ void LoopStrengthReduce::getAnalysisUsage(AnalysisUsage &AU) const { // We split critical edges, so we change the CFG. However, we do update // many analyses if they are around. AU.addPreservedID(LoopSimplifyID); - AU.addPreserved("domfrontier"); AU.addRequired(); AU.addPreserved(); diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp index c5b97070494..5d3af3759a0 100644 --- a/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -19,7 +19,7 @@ #include "llvm/Constant.h" #include "llvm/Type.h" #include "llvm/Analysis/AliasAnalysis.h" -#include "llvm/Analysis/DominanceFrontier.h" +#include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/MemoryDependenceAnalysis.h" #include "llvm/Target/TargetData.h" @@ -311,9 +311,6 @@ BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction *SplitPt, Pass *P) { DT->changeImmediateDominator(*I, NewNode); } - if (DominanceFrontier *DF = P->getAnalysisIfAvailable()) - DF->splitBlock(Old); - return New; } @@ -325,10 +322,9 @@ BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction *SplitPt, Pass *P) { /// suffix of 'Suffix'. /// /// This currently updates the LLVM IR, AliasAnalysis, DominatorTree, -/// DominanceFrontier, LoopInfo, and LCCSA but no other analyses. -/// In particular, it does not preserve LoopSimplify (because it's -/// complicated to handle the case where one of the edges being split -/// is an exit of a loop with other exits). +/// LoopInfo, and LCCSA but no other analyses. In particular, it does not +/// preserve LoopSimplify (because it's complicated to handle the case where one +/// of the edges being split is an exit of a loop with other exits). /// BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB, BasicBlock *const *Preds, @@ -378,13 +374,10 @@ BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB, } } - // Update dominator tree and dominator frontier if available. + // Update dominator tree if available. DominatorTree *DT = P ? P->getAnalysisIfAvailable() : 0; if (DT) DT->splitBlock(NewBB); - if (DominanceFrontier *DF = - P ? P->getAnalysisIfAvailable() : 0) - DF->splitBlock(NewBB); // Insert a new PHI node into NewBB for every PHI node in BB and that new PHI // node becomes an incoming value for BB's phi node. However, if the Preds diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp index f886b223d7a..616b066b5ab 100644 --- a/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -11,15 +11,14 @@ // inserting a dummy basic block. This pass may be "required" by passes that // cannot deal with critical edges. For this usage, the structure type is // forward declared. This pass obviously invalidates the CFG, but can update -// forward dominator (set, immediate dominators, tree, and frontier) -// information. +// dominator trees. // //===----------------------------------------------------------------------===// #define DEBUG_TYPE "break-crit-edges" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" -#include "llvm/Analysis/DominanceFrontier.h" +#include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/ProfileInfo.h" #include "llvm/Function.h" @@ -44,7 +43,6 @@ namespace { virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addPreserved(); - AU.addPreserved(); AU.addPreserved(); AU.addPreserved(); @@ -152,10 +150,9 @@ static void CreatePHIsForSplitLoopExit(SmallVectorImpl &Preds, } /// SplitCriticalEdge - If this edge is a critical edge, insert a new node to -/// split the critical edge. This will update DominatorTree and -/// DominatorFrontier information if it is available, thus calling this pass -/// will not invalidate either of them. This returns the new block if the edge -/// was split, null otherwise. +/// split the critical edge. This will update DominatorTree information if it +/// is available, thus calling this pass will not invalidate either of them. +/// This returns the new block if the edge was split, null otherwise. /// /// If MergeIdenticalEdges is true (not the default), *all* edges from TI to the /// specified successor will be merged into the same critical edge block. @@ -257,12 +254,11 @@ BasicBlock *llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, if (P == 0) return NewBB; DominatorTree *DT = P->getAnalysisIfAvailable(); - DominanceFrontier *DF = P->getAnalysisIfAvailable(); LoopInfo *LI = P->getAnalysisIfAvailable(); ProfileInfo *PI = P->getAnalysisIfAvailable(); // If we have nothing to update, just return. - if (DT == 0 && DF == 0 && LI == 0 && PI == 0) + if (DT == 0 && LI == 0 && PI == 0) return NewBB; // Now update analysis information. Since the only predecessor of NewBB is @@ -320,40 +316,6 @@ BasicBlock *llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, } } - // Should we update DominanceFrontier information? - if (DF) { - // If NewBBDominatesDestBB hasn't been computed yet, do so with DF. - if (!OtherPreds.empty()) { - // FIXME: IMPLEMENT THIS! - llvm_unreachable("Requiring domfrontiers but not idom/domtree/domset." - " not implemented yet!"); - } - - // Since the new block is dominated by its only predecessor TIBB, - // it cannot be in any block's dominance frontier. If NewBB dominates - // DestBB, its dominance frontier is the same as DestBB's, otherwise it is - // just {DestBB}. - DominanceFrontier::DomSetType NewDFSet; - if (NewBBDominatesDestBB) { - DominanceFrontier::iterator I = DF->find(DestBB); - if (I != DF->end()) { - DF->addBasicBlock(NewBB, I->second); - - if (I->second.count(DestBB)) { - // However NewBB's frontier does not include DestBB. - DominanceFrontier::iterator NF = DF->find(NewBB); - DF->removeFromFrontier(NF, DestBB); - } - } - else - DF->addBasicBlock(NewBB, DominanceFrontier::DomSetType()); - } else { - DominanceFrontier::DomSetType NewDFSet; - NewDFSet.insert(DestBB); - DF->addBasicBlock(NewBB, NewDFSet); - } - } - // Update LoopInfo if it is around. if (LI) { if (Loop *TIL = LI->getLoopFor(TIBB)) { diff --git a/lib/Transforms/Utils/CloneLoop.cpp b/lib/Transforms/Utils/CloneLoop.cpp index 6076ae772e8..87dd14153a1 100644 --- a/lib/Transforms/Utils/CloneLoop.cpp +++ b/lib/Transforms/Utils/CloneLoop.cpp @@ -14,17 +14,16 @@ #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/BasicBlock.h" #include "llvm/Analysis/LoopPass.h" -#include "llvm/Analysis/DominanceFrontier.h" +#include "llvm/Analysis/Dominators.h" using namespace llvm; -/// CloneDominatorInfo - Clone basicblock's dominator tree and, if available, -/// dominance info. It is expected that basic block is already cloned. +/// CloneDominatorInfo - Clone a basic block's dominator tree. It is expected +/// that the basic block is already cloned. static void CloneDominatorInfo(BasicBlock *BB, ValueToValueMapTy &VMap, - DominatorTree *DT, - DominanceFrontier *DF) { + DominatorTree *DT) { assert (DT && "DominatorTree is not available"); ValueToValueMapTy::iterator BI = VMap.find(BB); @@ -46,28 +45,9 @@ static void CloneDominatorInfo(BasicBlock *BB, if (BBDomI != VMap.end()) { NewBBDom = cast(BBDomI->second); if (!DT->getNode(NewBBDom)) - CloneDominatorInfo(BBDom, VMap, DT, DF); + CloneDominatorInfo(BBDom, VMap, DT); } DT->addNewBlock(NewBB, NewBBDom); - - // Copy cloned dominance frontiner set - if (DF) { - DominanceFrontier::DomSetType NewDFSet; - DominanceFrontier::iterator DFI = DF->find(BB); - if ( DFI != DF->end()) { - DominanceFrontier::DomSetType S = DFI->second; - for (DominanceFrontier::DomSetType::iterator I = S.begin(), E = S.end(); - I != E; ++I) { - BasicBlock *DB = *I; - ValueToValueMapTy::iterator IDM = VMap.find(DB); - if (IDM != VMap.end()) - NewDFSet.insert(cast(IDM->second)); - else - NewDFSet.insert(DB); - } - } - DF->addBasicBlock(NewBB, NewDFSet); - } } /// CloneLoop - Clone Loop. Clone dominator info. Populate VMap @@ -76,11 +56,8 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager *LPM, LoopInfo *LI, ValueToValueMapTy &VMap, Pass *P) { DominatorTree *DT = NULL; - DominanceFrontier *DF = NULL; - if (P) { + if (P) DT = P->getAnalysisIfAvailable(); - DF = P->getAnalysisIfAvailable(); - } SmallVector NewBlocks; @@ -116,7 +93,7 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager *LPM, LoopInfo *LI, for (Loop::block_iterator I = L->block_begin(), E = L->block_end(); I != E; ++I) { BasicBlock *BB = *I; - CloneDominatorInfo(BB, VMap, DT, DF); + CloneDominatorInfo(BB, VMap, DT); } // Process sub loops diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index efb4d3661b1..b237824da13 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -46,7 +46,7 @@ #include "llvm/LLVMContext.h" #include "llvm/Type.h" #include "llvm/Analysis/AliasAnalysis.h" -#include "llvm/Analysis/DominanceFrontier.h" +#include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/ScalarEvolution.h" @@ -90,7 +90,6 @@ namespace { AU.addPreserved(); AU.addPreserved(); AU.addPreservedID(BreakCriticalEdgesID); // No critical edges added. - AU.addPreserved(); } /// verifyAnalysis() - Verify LoopSimplifyForm's guarantees. @@ -322,7 +321,7 @@ ReprocessLoop: if (!FoldBranchToCommonDest(BI)) continue; // Success. The block is now dead, so remove it from the loop, - // update the dominator tree and dominance frontier, and delete it. + // update the dominator tree and delete it. DEBUG(dbgs() << "LoopSimplify: Eliminating exiting block " << ExitingBlock->getName() << "\n"); @@ -330,19 +329,14 @@ ReprocessLoop: Changed = true; LI->removeBlock(ExitingBlock); - DominanceFrontier *DF = getAnalysisIfAvailable(); DomTreeNode *Node = DT->getNode(ExitingBlock); const std::vector *> &Children = Node->getChildren(); while (!Children.empty()) { DomTreeNode *Child = Children.front(); DT->changeImmediateDominator(Child, Node->getIDom()); - if (DF) DF->changeImmediateDominator(Child->getBlock(), - Node->getIDom()->getBlock(), - DT); } DT->eraseNode(ExitingBlock); - if (DF) DF->removeBlock(ExitingBlock); BI->getSuccessor(0)->removePredecessor(ExitingBlock); BI->getSuccessor(1)->removePredecessor(ExitingBlock); @@ -720,8 +714,6 @@ LoopSimplify::InsertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader) { // Update dominator information DT->splitBlock(BEBlock); - if (DominanceFrontier *DF = getAnalysisIfAvailable()) - DF->splitBlock(BEBlock); return BEBlock; }