diff options
| author | Jakub Kuderski <kubakuderski@gmail.com> | 2018-07-04 18:37:15 +0000 |
|---|---|---|
| committer | Jakub Kuderski <kubakuderski@gmail.com> | 2018-07-04 18:37:15 +0000 |
| commit | bea19a9493b7286a0c79a8be2b788bed8cb4cfa9 (patch) | |
| tree | b602c0b3ceb1a646d8fad4f8582207d1a227a353 /llvm/unittests | |
| parent | 9c2e7ceb1a0d77a619b247d3be4774f209fd0d02 (diff) | |
| download | bcm5719-llvm-bea19a9493b7286a0c79a8be2b788bed8cb4cfa9.tar.gz bcm5719-llvm-bea19a9493b7286a0c79a8be2b788bed8cb4cfa9.zip | |
[Dominators] Add DomTreeUpdater constructor from DT* and PDT*
Summary:
Previously, if a function accepts an optional DT pointer,
```
void Foo (.., DominatorTree * DT = nullptr) {
...
if(DT)
DomTreeUpdater(*DT, ...).insertEdge(A, B);
if(DT){
DomTreeUpdater DTU(*DT, ...);
... // Construct the update vector and applyUpdates
}
...
if(DT){
DomTreeUpdater DTU(*DT, ...);
... // Construct the update vector and applyUpdates
}
}
```
After this patch, it can be simplified as
```
void Foo (.., DominatorTree * DT = nullptr) {
DomTreeUpdater DTU(DT, ...);
...
DTU.insertEdge(A, B);
if(DT){
... // Construct the update vector and applyUpdates
}
...
if(DT){
... // Construct the update vector and applyUpdates
}
}
```
Patch by Chijun Sima <simachijun@gmail.com>.
Reviewers: kuhar, brzycki, dmgreen
Reviewed By: kuhar
Author: NutshellySima
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D48923
llvm-svn: 336294
Diffstat (limited to 'llvm/unittests')
| -rw-r--r-- | llvm/unittests/IR/DomTreeUpdaterTest.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/unittests/IR/DomTreeUpdaterTest.cpp b/llvm/unittests/IR/DomTreeUpdaterTest.cpp index a6d768920bc..f431fa21039 100644 --- a/llvm/unittests/IR/DomTreeUpdaterTest.cpp +++ b/llvm/unittests/IR/DomTreeUpdaterTest.cpp @@ -235,7 +235,8 @@ TEST(DomTreeUpdater, LazyUpdateDTBasicOperations) { // Make the DTU. DominatorTree DT(*F); - DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy); + PostDominatorTree *PDT = nullptr; + DomTreeUpdater DTU(&DT, PDT, DomTreeUpdater::UpdateStrategy::Lazy); ASSERT_TRUE(DTU.hasDomTree()); ASSERT_FALSE(DTU.hasPostDomTree()); ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Lazy); @@ -323,7 +324,8 @@ TEST(DomTreeUpdater, LazyUpdateDTInheritedPreds) { // Make the DTU. DominatorTree DT(*F); - DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy); + PostDominatorTree *PDT = nullptr; + DomTreeUpdater DTU(&DT, PDT, DomTreeUpdater::UpdateStrategy::Lazy); ASSERT_TRUE(DTU.hasDomTree()); ASSERT_FALSE(DTU.hasPostDomTree()); ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Lazy); @@ -449,7 +451,7 @@ TEST(DomTreeUpdater, LazyUpdateBasicOperations) { // Make the DTU. DominatorTree DT(*F); PostDominatorTree PDT(*F); - DomTreeUpdater DTU(DT, PDT, DomTreeUpdater::UpdateStrategy::Lazy); + DomTreeUpdater DTU(&DT, &PDT, DomTreeUpdater::UpdateStrategy::Lazy); ASSERT_TRUE(DTU.hasDomTree()); ASSERT_TRUE(DTU.hasPostDomTree()); ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Lazy); |

