llvm.org GIT mirror llvm / 96a3f3e
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336294 91177308-0d34-0410-b5e6-96231b3b80d8 Jakub Kuderski 1 year, 3 months ago
2 changed file(s) with 12 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
3030 explicit DomTreeUpdater(UpdateStrategy Strategy_) : Strategy(Strategy_) {}
3131 DomTreeUpdater(DominatorTree &DT_, UpdateStrategy Strategy_)
3232 : DT(&DT_), Strategy(Strategy_) {}
33 DomTreeUpdater(DominatorTree *DT_, UpdateStrategy Strategy_)
34 : DT(DT_), Strategy(Strategy_) {}
3335 DomTreeUpdater(PostDominatorTree &PDT_, UpdateStrategy Strategy_)
3436 : PDT(&PDT_), Strategy(Strategy_) {}
37 DomTreeUpdater(PostDominatorTree *PDT_, UpdateStrategy Strategy_)
38 : PDT(PDT_), Strategy(Strategy_) {}
3539 DomTreeUpdater(DominatorTree &DT_, PostDominatorTree &PDT_,
3640 UpdateStrategy Strategy_)
3741 : DT(&DT_), PDT(&PDT_), Strategy(Strategy_) {}
42 DomTreeUpdater(DominatorTree *DT_, PostDominatorTree *PDT_,
43 UpdateStrategy Strategy_)
44 : DT(DT_), PDT(PDT_), Strategy(Strategy_) {}
3845
3946 ~DomTreeUpdater() { flush(); }
4047
234234
235235 // Make the DTU.
236236 DominatorTree DT(*F);
237 DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
237 PostDominatorTree *PDT = nullptr;
238 DomTreeUpdater DTU(&DT, PDT, DomTreeUpdater::UpdateStrategy::Lazy);
238239 ASSERT_TRUE(DTU.hasDomTree());
239240 ASSERT_FALSE(DTU.hasPostDomTree());
240241 ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Lazy);
322323
323324 // Make the DTU.
324325 DominatorTree DT(*F);
325 DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
326 PostDominatorTree *PDT = nullptr;
327 DomTreeUpdater DTU(&DT, PDT, DomTreeUpdater::UpdateStrategy::Lazy);
326328 ASSERT_TRUE(DTU.hasDomTree());
327329 ASSERT_FALSE(DTU.hasPostDomTree());
328330 ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Lazy);
448450 // Make the DTU.
449451 DominatorTree DT(*F);
450452 PostDominatorTree PDT(*F);
451 DomTreeUpdater DTU(DT, PDT, DomTreeUpdater::UpdateStrategy::Lazy);
453 DomTreeUpdater DTU(&DT, &PDT, DomTreeUpdater::UpdateStrategy::Lazy);
452454 ASSERT_TRUE(DTU.hasDomTree());
453455 ASSERT_TRUE(DTU.hasPostDomTree());
454456 ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Lazy);