llvm.org GIT mirror llvm / 04d4b7f
[Dominators] Add isUpdateLazy() method to the DomTreeUpdater Summary: Previously, when people need to deal with DTU with different UpdateStrategy using different actions, they need to ``` if (DTU.getUpdateStrategy() == DomTreeUpdater::UpdateStrategy::Lazy) { ... } if (DTU.getUpdateStrategy() == DomTreeUpdater::UpdateStrategy::Eager) { ... } ``` After the patch, they can avoid code patterns above ``` if (DTU.isUpdateLazy()){ ... } if (!DTU.isUpdateLazy()){ ... } ``` Reviewers: kuhar, brzycki, dmgreen Reviewed By: kuhar Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49056 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336886 91177308-0d34-0410-b5e6-96231b3b80d8 Chijun Sima 1 year, 3 months ago
2 changed file(s) with 19 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
4545
4646 ~DomTreeUpdater() { flush(); }
4747
48 /// Returns the UpdateStrategy of the class instance.
49 UpdateStrategy getUpdateStrategy() const { return Strategy; };
48 /// Returns true if the current strategy is Lazy.
49 bool isLazy() const { return Strategy == UpdateStrategy::Lazy; };
50
51 /// Returns true if the current strategy is Eager.
52 bool isEager() const { return Strategy == UpdateStrategy::Eager; };
5053
5154 /// Returns true if it holds a DominatorTree.
5255 bool hasDomTree() const { return DT != nullptr; }
5757
5858 ASSERT_TRUE(DTU.hasDomTree());
5959 ASSERT_TRUE(DTU.hasPostDomTree());
60 ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Eager);
60 ASSERT_TRUE(DTU.isEager());
61 ASSERT_FALSE(DTU.isLazy());
6162 ASSERT_TRUE(DTU.getDomTree().verify());
6263 ASSERT_TRUE(DTU.getPostDomTree().verify());
6364 ASSERT_FALSE(DTU.hasPendingUpdates());
165166 DomTreeUpdater DTU(DT, PDT, DomTreeUpdater::UpdateStrategy::Eager);
166167 ASSERT_TRUE(DTU.hasDomTree());
167168 ASSERT_TRUE(DTU.hasPostDomTree());
168 ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Eager);
169 ASSERT_TRUE(DTU.isEager());
170 ASSERT_FALSE(DTU.isLazy());
169171 ASSERT_TRUE(DT.verify());
170172 ASSERT_TRUE(PDT.verify());
171173
238240 DomTreeUpdater DTU(&DT, PDT, DomTreeUpdater::UpdateStrategy::Lazy);
239241 ASSERT_TRUE(DTU.hasDomTree());
240242 ASSERT_FALSE(DTU.hasPostDomTree());
241 ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Lazy);
243 ASSERT_FALSE(DTU.isEager());
244 ASSERT_TRUE(DTU.isLazy());
242245 ASSERT_TRUE(DTU.getDomTree().verify());
243246
244247 Function::iterator FI = F->begin();
326329 DomTreeUpdater DTU(&DT, PDT, DomTreeUpdater::UpdateStrategy::Lazy);
327330 ASSERT_TRUE(DTU.hasDomTree());
328331 ASSERT_FALSE(DTU.hasPostDomTree());
329 ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Lazy);
332 ASSERT_FALSE(DTU.isEager());
333 ASSERT_TRUE(DTU.isLazy());
330334 ASSERT_TRUE(DTU.getDomTree().verify());
331335
332336 Function::iterator FI = F->begin();
452456 DomTreeUpdater DTU(&DT, &PDT, DomTreeUpdater::UpdateStrategy::Lazy);
453457 ASSERT_TRUE(DTU.hasDomTree());
454458 ASSERT_TRUE(DTU.hasPostDomTree());
455 ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Lazy);
459 ASSERT_FALSE(DTU.isEager());
460 ASSERT_TRUE(DTU.isLazy());
456461 ASSERT_TRUE(DTU.getDomTree().verify());
457462 ASSERT_TRUE(DTU.getPostDomTree().verify());
458463
534539 DomTreeUpdater DTU(DT, PDT, DomTreeUpdater::UpdateStrategy::Lazy);
535540 ASSERT_TRUE(DTU.hasDomTree());
536541 ASSERT_TRUE(DTU.hasPostDomTree());
537 ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Lazy);
542 ASSERT_FALSE(DTU.isEager());
543 ASSERT_TRUE(DTU.isLazy());
538544 ASSERT_TRUE(DTU.getDomTree().verify());
539545 ASSERT_TRUE(DTU.getPostDomTree().verify());
540546
623629
624630 ASSERT_TRUE(DTU.hasDomTree());
625631 ASSERT_TRUE(DTU.hasPostDomTree());
626 ASSERT_EQ(DTU.getUpdateStrategy(), DomTreeUpdater::UpdateStrategy::Lazy);
632 ASSERT_FALSE(DTU.isEager());
633 ASSERT_TRUE(DTU.isLazy());
627634 ASSERT_TRUE(DTU.getDomTree().verify());
628635 ASSERT_TRUE(DTU.getPostDomTree().verify());
629636 ASSERT_FALSE(DTU.hasPendingUpdates());