[PATCH] D49988: [ADCE] Remove the need of DomTree
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 3 19:50:38 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338950: [ADCE] Remove the need of DomTree (authored by sima, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D49988?vs=158773&id=159159#toc
Repository:
rL LLVM
https://reviews.llvm.org/D49988
Files:
llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
llvm/trunk/test/Transforms/LoopRotate/pr35210.ll
Index: llvm/trunk/test/Transforms/LoopRotate/pr35210.ll
===================================================================
--- llvm/trunk/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/trunk/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.
Index: llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
+++ llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
@@ -116,7 +116,7 @@
// 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 @@
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 @@
}
}
- DomTreeUpdater(DT, PDT, DomTreeUpdater::UpdateStrategy::Eager)
+ DomTreeUpdater(DT, &PDT, DomTreeUpdater::UpdateStrategy::Eager)
.applyUpdates(DeletedEdges);
NumBranchesRemoved += 1;
@@ -672,7 +672,9 @@
//
//===----------------------------------------------------------------------===//
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 @@
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 @@
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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49988.159159.patch
Type: text/x-patch
Size: 3800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180804/26093609/attachment.bin>
More information about the llvm-commits
mailing list