diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2014-01-13 13:07:17 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2014-01-13 13:07:17 +0000 |
| commit | 73523021d0a97c150a76a5cf4a91e99cd03b9efb (patch) | |
| tree | d2719d151f36e8afd70aee405bd992cd52a2022c /llvm/lib/Analysis | |
| parent | ca9af6cad9e8c57c6e04ecffb19bb56493ab7608 (diff) | |
| download | bcm5719-llvm-73523021d0a97c150a76a5cf4a91e99cd03b9efb.tar.gz bcm5719-llvm-73523021d0a97c150a76a5cf4a91e99cd03b9efb.zip | |
[PM] Split DominatorTree into a concrete analysis result object which
can be used by both the new pass manager and the old.
This removes it from any of the virtual mess of the pass interfaces and
lets it derive cleanly from the DominatorTreeBase<> template. In turn,
tons of boilerplate interface can be nuked and it turns into a very
straightforward extension of the base DominatorTree interface.
The old analysis pass is now a simple wrapper. The names and style of
this split should match the split between CallGraph and
CallGraphWrapperPass. All of the users of DominatorTree have been
updated to match using many of the same tricks as with CallGraph. The
goal is that the common type remains the resulting DominatorTree rather
than the pass. This will make subsequent work toward the new pass
manager significantly easier.
Also in numerous places things became cleaner because I switched from
re-running the pass (!!! mid way through some other passes run!!!) to
directly recomputing the domtree.
llvm-svn: 199104
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/BasicAliasAnalysis.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Analysis/DomPrinter.cpp | 46 | ||||
| -rw-r--r-- | llvm/lib/Analysis/DominanceFrontier.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Analysis/IVUsers.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Analysis/Lint.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Analysis/RegionInfo.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 6 |
9 files changed, 56 insertions, 30 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 615411f29c1..404c5405933 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -1335,7 +1335,9 @@ bool BasicAliasAnalysis::isValueEqualInPotentialCycles(const Value *V, return false; // Use dominance or loop info if available. - DominatorTree *DT = getAnalysisIfAvailable<DominatorTree>(); + DominatorTreeWrapperPass *DTWP = + getAnalysisIfAvailable<DominatorTreeWrapperPass>(); + DominatorTree *DT = DTWP ? &DTWP->getDomTree() : 0; LoopInfo *LI = getAnalysisIfAvailable<LoopInfo>(); // Make sure that the visited phis cannot reach the Value. This ensures that diff --git a/llvm/lib/Analysis/DomPrinter.cpp b/llvm/lib/Analysis/DomPrinter.cpp index cde431459d5..0c880df54f8 100644 --- a/llvm/lib/Analysis/DomPrinter.cpp +++ b/llvm/lib/Analysis/DomPrinter.cpp @@ -81,18 +81,32 @@ struct DOTGraphTraits<PostDominatorTree*> } namespace { -struct DomViewer - : public DOTGraphTraitsViewer<DominatorTree, false> { +struct DominatorTreeWrapperPassAnalysisGraphTraits { + static DominatorTree *getGraph(DominatorTreeWrapperPass *DTWP) { + return &DTWP->getDomTree(); + } +}; + +struct DomViewer : public DOTGraphTraitsViewer< + DominatorTreeWrapperPass, false, DominatorTree *, + DominatorTreeWrapperPassAnalysisGraphTraits> { static char ID; - DomViewer() : DOTGraphTraitsViewer<DominatorTree, false>("dom", ID){ + DomViewer() + : DOTGraphTraitsViewer<DominatorTreeWrapperPass, false, DominatorTree *, + DominatorTreeWrapperPassAnalysisGraphTraits>( + "dom", ID) { initializeDomViewerPass(*PassRegistry::getPassRegistry()); } }; -struct DomOnlyViewer - : public DOTGraphTraitsViewer<DominatorTree, true> { +struct DomOnlyViewer : public DOTGraphTraitsViewer< + DominatorTreeWrapperPass, true, DominatorTree *, + DominatorTreeWrapperPassAnalysisGraphTraits> { static char ID; - DomOnlyViewer() : DOTGraphTraitsViewer<DominatorTree, true>("domonly", ID){ + DomOnlyViewer() + : DOTGraphTraitsViewer<DominatorTreeWrapperPass, true, DominatorTree *, + DominatorTreeWrapperPassAnalysisGraphTraits>( + "domonly", ID) { initializeDomOnlyViewerPass(*PassRegistry::getPassRegistry()); } }; @@ -136,18 +150,26 @@ INITIALIZE_PASS(PostDomOnlyViewer, "view-postdom-only", false, false) namespace { -struct DomPrinter - : public DOTGraphTraitsPrinter<DominatorTree, false> { +struct DomPrinter : public DOTGraphTraitsPrinter< + DominatorTreeWrapperPass, false, DominatorTree *, + DominatorTreeWrapperPassAnalysisGraphTraits> { static char ID; - DomPrinter() : DOTGraphTraitsPrinter<DominatorTree, false>("dom", ID) { + DomPrinter() + : DOTGraphTraitsPrinter<DominatorTreeWrapperPass, false, DominatorTree *, + DominatorTreeWrapperPassAnalysisGraphTraits>( + "dom", ID) { initializeDomPrinterPass(*PassRegistry::getPassRegistry()); } }; -struct DomOnlyPrinter - : public DOTGraphTraitsPrinter<DominatorTree, true> { +struct DomOnlyPrinter : public DOTGraphTraitsPrinter< + DominatorTreeWrapperPass, true, DominatorTree *, + DominatorTreeWrapperPassAnalysisGraphTraits> { static char ID; - DomOnlyPrinter() : DOTGraphTraitsPrinter<DominatorTree, true>("domonly", ID) { + DomOnlyPrinter() + : DOTGraphTraitsPrinter<DominatorTreeWrapperPass, true, DominatorTree *, + DominatorTreeWrapperPassAnalysisGraphTraits>( + "domonly", ID) { initializeDomOnlyPrinterPass(*PassRegistry::getPassRegistry()); } }; diff --git a/llvm/lib/Analysis/DominanceFrontier.cpp b/llvm/lib/Analysis/DominanceFrontier.cpp index 74cd15815f9..f0787f11409 100644 --- a/llvm/lib/Analysis/DominanceFrontier.cpp +++ b/llvm/lib/Analysis/DominanceFrontier.cpp @@ -16,7 +16,7 @@ using namespace llvm; char DominanceFrontier::ID = 0; INITIALIZE_PASS_BEGIN(DominanceFrontier, "domfrontier", "Dominance Frontier Construction", true, true) -INITIALIZE_PASS_DEPENDENCY(DominatorTree) +INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_END(DominanceFrontier, "domfrontier", "Dominance Frontier Construction", true, true) diff --git a/llvm/lib/Analysis/IVUsers.cpp b/llvm/lib/Analysis/IVUsers.cpp index e021bd70c92..eacd4eb029d 100644 --- a/llvm/lib/Analysis/IVUsers.cpp +++ b/llvm/lib/Analysis/IVUsers.cpp @@ -33,7 +33,7 @@ char IVUsers::ID = 0; INITIALIZE_PASS_BEGIN(IVUsers, "iv-users", "Induction Variable Users", false, true) INITIALIZE_PASS_DEPENDENCY(LoopInfo) -INITIALIZE_PASS_DEPENDENCY(DominatorTree) +INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) INITIALIZE_PASS_END(IVUsers, "iv-users", "Induction Variable Users", false, true) @@ -223,7 +223,7 @@ IVUsers::IVUsers() void IVUsers::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<LoopInfo>(); - AU.addRequired<DominatorTree>(); + AU.addRequired<DominatorTreeWrapperPass>(); AU.addRequired<ScalarEvolution>(); AU.setPreservesAll(); } @@ -232,7 +232,7 @@ bool IVUsers::runOnLoop(Loop *l, LPPassManager &LPM) { L = l; LI = &getAnalysis<LoopInfo>(); - DT = &getAnalysis<DominatorTree>(); + DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); SE = &getAnalysis<ScalarEvolution>(); TD = getAnalysisIfAvailable<DataLayout>(); diff --git a/llvm/lib/Analysis/Lint.cpp b/llvm/lib/Analysis/Lint.cpp index da052b4fca4..7c0ead64ae6 100644 --- a/llvm/lib/Analysis/Lint.cpp +++ b/llvm/lib/Analysis/Lint.cpp @@ -119,7 +119,7 @@ namespace { AU.setPreservesAll(); AU.addRequired<AliasAnalysis>(); AU.addRequired<TargetLibraryInfo>(); - AU.addRequired<DominatorTree>(); + AU.addRequired<DominatorTreeWrapperPass>(); } virtual void print(raw_ostream &O, const Module *M) const {} @@ -152,7 +152,7 @@ char Lint::ID = 0; INITIALIZE_PASS_BEGIN(Lint, "lint", "Statically lint-checks LLVM IR", false, true) INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo) -INITIALIZE_PASS_DEPENDENCY(DominatorTree) +INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_AG_DEPENDENCY(AliasAnalysis) INITIALIZE_PASS_END(Lint, "lint", "Statically lint-checks LLVM IR", false, true) @@ -175,7 +175,7 @@ INITIALIZE_PASS_END(Lint, "lint", "Statically lint-checks LLVM IR", bool Lint::runOnFunction(Function &F) { Mod = F.getParent(); AA = &getAnalysis<AliasAnalysis>(); - DT = &getAnalysis<DominatorTree>(); + DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); TD = getAnalysisIfAvailable<DataLayout>(); TLI = &getAnalysis<TargetLibraryInfo>(); visit(F); diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 0d0b193f5be..c6c1f922f7d 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -46,7 +46,7 @@ VerifyLoopInfoX("verify-loop-info", cl::location(VerifyLoopInfo), char LoopInfo::ID = 0; INITIALIZE_PASS_BEGIN(LoopInfo, "loops", "Natural Loop Information", true, true) -INITIALIZE_PASS_DEPENDENCY(DominatorTree) +INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_END(LoopInfo, "loops", "Natural Loop Information", true, true) // Loop identifier metadata name. @@ -613,7 +613,7 @@ Loop *UnloopUpdater::getNearestLoop(BasicBlock *BB, Loop *BBLoop) { // bool LoopInfo::runOnFunction(Function &) { releaseMemory(); - LI.Analyze(getAnalysis<DominatorTree>().getBase()); + LI.Analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree()); return false; } @@ -704,7 +704,7 @@ void LoopInfo::verifyAnalysis() const { void LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); - AU.addRequired<DominatorTree>(); + AU.addRequired<DominatorTreeWrapperPass>(); } void LoopInfo::print(raw_ostream &OS, const Module*) const { diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index 48cf1489edb..dc07ac8c5d3 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -88,7 +88,9 @@ void MemoryDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { bool MemoryDependenceAnalysis::runOnFunction(Function &) { AA = &getAnalysis<AliasAnalysis>(); TD = getAnalysisIfAvailable<DataLayout>(); - DT = getAnalysisIfAvailable<DominatorTree>(); + DominatorTreeWrapperPass *DTWP = + getAnalysisIfAvailable<DominatorTreeWrapperPass>(); + DT = DTWP ? &DTWP->getDomTree() : 0; if (!PredCache) PredCache.reset(new PredIteratorCache()); return false; diff --git a/llvm/lib/Analysis/RegionInfo.cpp b/llvm/lib/Analysis/RegionInfo.cpp index f732ffdde07..876d86b785b 100644 --- a/llvm/lib/Analysis/RegionInfo.cpp +++ b/llvm/lib/Analysis/RegionInfo.cpp @@ -706,7 +706,7 @@ void RegionInfo::Calculate(Function &F) { bool RegionInfo::runOnFunction(Function &F) { releaseMemory(); - DT = &getAnalysis<DominatorTree>(); + DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); PDT = &getAnalysis<PostDominatorTree>(); DF = &getAnalysis<DominanceFrontier>(); @@ -720,7 +720,7 @@ bool RegionInfo::runOnFunction(Function &F) { void RegionInfo::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); - AU.addRequiredTransitive<DominatorTree>(); + AU.addRequiredTransitive<DominatorTreeWrapperPass>(); AU.addRequired<PostDominatorTree>(); AU.addRequired<DominanceFrontier>(); } @@ -846,7 +846,7 @@ void RegionInfo::splitBlock(BasicBlock* NewBB, BasicBlock *OldBB) char RegionInfo::ID = 0; INITIALIZE_PASS_BEGIN(RegionInfo, "regions", "Detect single entry single exit regions", true, true) -INITIALIZE_PASS_DEPENDENCY(DominatorTree) +INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(PostDominatorTree) INITIALIZE_PASS_DEPENDENCY(DominanceFrontier) INITIALIZE_PASS_END(RegionInfo, "regions", diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 0cd18d205c8..0067d0c3860 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -113,7 +113,7 @@ VerifySCEV("verify-scev", INITIALIZE_PASS_BEGIN(ScalarEvolution, "scalar-evolution", "Scalar Evolution Analysis", false, true) INITIALIZE_PASS_DEPENDENCY(LoopInfo) -INITIALIZE_PASS_DEPENDENCY(DominatorTree) +INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo) INITIALIZE_PASS_END(ScalarEvolution, "scalar-evolution", "Scalar Evolution Analysis", false, true) @@ -7268,7 +7268,7 @@ bool ScalarEvolution::runOnFunction(Function &F) { LI = &getAnalysis<LoopInfo>(); TD = getAnalysisIfAvailable<DataLayout>(); TLI = &getAnalysis<TargetLibraryInfo>(); - DT = &getAnalysis<DominatorTree>(); + DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); return false; } @@ -7305,7 +7305,7 @@ void ScalarEvolution::releaseMemory() { void ScalarEvolution::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); AU.addRequiredTransitive<LoopInfo>(); - AU.addRequiredTransitive<DominatorTree>(); + AU.addRequiredTransitive<DominatorTreeWrapperPass>(); AU.addRequired<TargetLibraryInfo>(); } |

