diff options
author | Chijun Sima <simachijun@gmail.com> | 2018-08-03 05:08:17 +0000 |
---|---|---|
committer | Chijun Sima <simachijun@gmail.com> | 2018-08-03 05:08:17 +0000 |
commit | 21a8b605a1b3672384c7b14804f0288e1778fa36 (patch) | |
tree | 3aefc70f737300a73f3c84859dfc91896c55f0a4 /llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp | |
parent | d092d0b17989f22bc595ac5be55a6939aa46de02 (diff) | |
download | bcm5719-llvm-21a8b605a1b3672384c7b14804f0288e1778fa36.tar.gz bcm5719-llvm-21a8b605a1b3672384c7b14804f0288e1778fa36.zip |
[Dominators] Convert existing passes and utils to use the DomTreeUpdater class
Summary:
This patch is the second in a series of patches related to the [[ http://lists.llvm.org/pipermail/llvm-dev/2018-June/123883.html | RFC - A new dominator tree updater for LLVM ]].
It converts passes (e.g. adce/jump-threading) and various functions which currently accept DDT in local.cpp and BasicBlockUtils.cpp to use the new DomTreeUpdater class.
These converted functions in utils can accept DomTreeUpdater with either UpdateStrategy and can deal with both DT and PDT held by the DomTreeUpdater.
Reviewers: brzycki, kuhar, dmgreen, grosser, davide
Reviewed By: brzycki
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D48967
llvm-svn: 338814
Diffstat (limited to 'llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp index 2f2d7f620a2..99402985f28 100644 --- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp +++ b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp @@ -19,7 +19,6 @@ #include "llvm/Analysis/GlobalsModRef.h" #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/LazyValueInfo.h" -#include "llvm/Transforms/Utils/Local.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CFG.h" @@ -28,6 +27,7 @@ #include "llvm/IR/ConstantRange.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/DomTreeUpdater.h" #include "llvm/IR/Function.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/InstrTypes.h" @@ -44,6 +44,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Scalar.h" +#include "llvm/Transforms/Utils/Local.h" #include <cassert> #include <utility> @@ -308,6 +309,7 @@ static bool processCmp(CmpInst *C, LazyValueInfo *LVI) { /// a case fires on every incoming edge then the entire switch can be removed /// and replaced with a branch to the case destination. static bool processSwitch(SwitchInst *SI, LazyValueInfo *LVI, DominatorTree *DT) { + DomTreeUpdater DTU(*DT, DomTreeUpdater::UpdateStrategy::Lazy); Value *Cond = SI->getCondition(); BasicBlock *BB = SI->getParent(); @@ -372,7 +374,7 @@ static bool processSwitch(SwitchInst *SI, LazyValueInfo *LVI, DominatorTree *DT) ++NumDeadCases; Changed = true; if (--SuccessorsCount[Succ] == 0) - DT->deleteEdge(BB, Succ); + DTU.deleteEdge(BB, Succ); continue; } if (State == LazyValueInfo::True) { @@ -389,15 +391,11 @@ static bool processSwitch(SwitchInst *SI, LazyValueInfo *LVI, DominatorTree *DT) ++CI; } - if (Changed) { + if (Changed) // If the switch has been simplified to the point where it can be replaced // by a branch then do so now. - DeferredDominance DDT(*DT); ConstantFoldTerminator(BB, /*DeleteDeadConditions = */ false, - /*TLI = */ nullptr, &DDT); - DDT.flush(); - } - + /*TLI = */ nullptr, &DTU); return Changed; } |