diff options
author | Chijun Sima <simachijun@gmail.com> | 2018-08-04 02:50:12 +0000 |
---|---|---|
committer | Chijun Sima <simachijun@gmail.com> | 2018-08-04 02:50:12 +0000 |
commit | eacad7977752ac8ef50321cf4a51c2f6e0039ed6 (patch) | |
tree | 9fd61c8fef90360ce5cdcc6aeec7864748bcc9a8 /llvm | |
parent | 3da16f839338e06fab74a2199f06c7b3d614b032 (diff) | |
download | bcm5719-llvm-eacad7977752ac8ef50321cf4a51c2f6e0039ed6.tar.gz bcm5719-llvm-eacad7977752ac8ef50321cf4a51c2f6e0039ed6.zip |
[ADCE] Remove the need of DomTree
Summary: ADCE doesn't need to query domtree.
Reviewers: kuhar, brzycki, dmgreen, davide, grosser
Reviewed By: kuhar
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D49988
llvm-svn: 338950
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/Scalar/ADCE.cpp | 18 | ||||
-rw-r--r-- | llvm/test/Transforms/LoopRotate/pr35210.ll | 2 |
2 files changed, 11 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp index 1cda09a5781..d134a158073 100644 --- a/llvm/lib/Transforms/Scalar/ADCE.cpp +++ b/llvm/lib/Transforms/Scalar/ADCE.cpp @@ -116,7 +116,7 @@ class AggressiveDeadCodeElimination { // ADCE does not use DominatorTree per se, but it updates it to preserve the // analysis. - DominatorTree &DT; + DominatorTree *DT; PostDominatorTree &PDT; /// Mapping of blocks to associated information, an element in BlockInfoVec. @@ -191,7 +191,7 @@ class AggressiveDeadCodeElimination { void makeUnconditional(BasicBlock *BB, BasicBlock *Target); public: - AggressiveDeadCodeElimination(Function &F, DominatorTree &DT, + AggressiveDeadCodeElimination(Function &F, DominatorTree *DT, PostDominatorTree &PDT) : F(F), DT(DT), PDT(PDT) {} @@ -615,7 +615,7 @@ void AggressiveDeadCodeElimination::updateDeadRegions() { } } - DomTreeUpdater(DT, PDT, DomTreeUpdater::UpdateStrategy::Eager) + DomTreeUpdater(DT, &PDT, DomTreeUpdater::UpdateStrategy::Eager) .applyUpdates(DeletedEdges); NumBranchesRemoved += 1; @@ -672,7 +672,9 @@ void AggressiveDeadCodeElimination::makeUnconditional(BasicBlock *BB, // //===----------------------------------------------------------------------===// PreservedAnalyses ADCEPass::run(Function &F, FunctionAnalysisManager &FAM) { - auto &DT = FAM.getResult<DominatorTreeAnalysis>(F); + // ADCE does not need DominatorTree, but require DominatorTree here + // to update analysis if it is already available. + auto *DT = FAM.getCachedResult<DominatorTreeAnalysis>(F); auto &PDT = FAM.getResult<PostDominatorTreeAnalysis>(F); if (!AggressiveDeadCodeElimination(F, DT, PDT).performDeadCodeElimination()) return PreservedAnalyses::all(); @@ -698,15 +700,16 @@ struct ADCELegacyPass : public FunctionPass { if (skipFunction(F)) return false; - auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree(); + // ADCE does not need DominatorTree, but require DominatorTree here + // to update analysis if it is already available. + auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>(); + auto *DT = DTWP ? &DTWP->getDomTree() : nullptr; auto &PDT = getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree(); return AggressiveDeadCodeElimination(F, DT, PDT) .performDeadCodeElimination(); } void getAnalysisUsage(AnalysisUsage &AU) const override { - // We require DominatorTree here only to update and thus preserve it. - AU.addRequired<DominatorTreeWrapperPass>(); AU.addRequired<PostDominatorTreeWrapperPass>(); if (!RemoveControlFlowFlag) AU.setPreservesCFG(); @@ -724,7 +727,6 @@ char ADCELegacyPass::ID = 0; INITIALIZE_PASS_BEGIN(ADCELegacyPass, "adce", "Aggressive Dead Code Elimination", false, false) -INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass) INITIALIZE_PASS_END(ADCELegacyPass, "adce", "Aggressive Dead Code Elimination", false, false) diff --git a/llvm/test/Transforms/LoopRotate/pr35210.ll b/llvm/test/Transforms/LoopRotate/pr35210.ll index 356c7db243b..e92ae4b4d8a 100644 --- a/llvm/test/Transforms/LoopRotate/pr35210.ll +++ b/llvm/test/Transforms/LoopRotate/pr35210.ll @@ -6,12 +6,12 @@ ; CHECK: Starting llvm::Function pass manager run. ; CHECK-NEXT: Running pass: ADCEPass on f -; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on f ; CHECK-NEXT: Running analysis: PostDominatorTreeAnalysis on f ; CHECK-NEXT: Running pass: FunctionToLoopPassAdaptor{{.*}} on f ; CHECK-NEXT: Starting llvm::Function pass manager run. ; CHECK-NEXT: Running pass: LoopSimplifyPass on f ; CHECK-NEXT: Running analysis: LoopAnalysis on f +; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on f ; CHECK-NEXT: Running analysis: AssumptionAnalysis on f ; CHECK-NEXT: Running pass: LCSSAPass on f ; CHECK-NEXT: Finished llvm::Function pass manager run. |