summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR/DomTreeUpdaterTest.cpp
diff options
context:
space:
mode:
authorChijun Sima <simachijun@gmail.com>2018-08-03 06:51:35 +0000
committerChijun Sima <simachijun@gmail.com>2018-08-03 06:51:35 +0000
commitc72ff1011d62cfc6ee3c8f96eacacf654a3308d4 (patch)
tree3950150eb047feb795b18953f906dbaa8e778a1d /llvm/unittests/IR/DomTreeUpdaterTest.cpp
parente902b7d0b0f87489b52953ea83b92bf66039f452 (diff)
downloadbcm5719-llvm-c72ff1011d62cfc6ee3c8f96eacacf654a3308d4.tar.gz
bcm5719-llvm-c72ff1011d62cfc6ee3c8f96eacacf654a3308d4.zip
[Dominators] Refine the logic of recalculate() in the DomTreeUpdater
Summary: This patch refines the logic of `recalculate()` in the `DomTreeUpdater` in the following two aspects: 1. Previously, `recalculate()` tests whether there are pending updates/BBs awaiting deletion and then do recalculation under Lazy UpdateStrategy; and do recalculation immediately under Eager UpdateStrategy. (The former behavior is inherited from the `DeferredDominance` class). This is an inconsistency between two strategies and there is no obvious reason to do this. So the behavior is changed to always recalculate available trees when calling `recalculate()`. 2. Fix the issue of when DTU under Lazy UpdateStrategy holds nothing but with BBs awaiting deletion, after calling `recalculate()`, BBs awaiting deletion aren't flushed. An additional unittest is added to cover this case. Reviewers: kuhar, dmgreen, brzycki, grosser, davide Reviewed By: kuhar Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50173 llvm-svn: 338822
Diffstat (limited to 'llvm/unittests/IR/DomTreeUpdaterTest.cpp')
-rw-r--r--llvm/unittests/IR/DomTreeUpdaterTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/unittests/IR/DomTreeUpdaterTest.cpp b/llvm/unittests/IR/DomTreeUpdaterTest.cpp
index 03b6b529fd8..db2bb80a79a 100644
--- a/llvm/unittests/IR/DomTreeUpdaterTest.cpp
+++ b/llvm/unittests/IR/DomTreeUpdaterTest.cpp
@@ -699,3 +699,29 @@ TEST(DomTreeUpdater, LazyUpdateStepTest) {
DTU.flush();
ASSERT_TRUE(DT.verify());
}
+
+TEST(DomTreeUpdater, NoTreeTest) {
+ StringRef FuncName = "f";
+ StringRef ModuleString = R"(
+ define i32 @f() {
+ bb0:
+ ret i32 0
+ }
+ )";
+ // Make the module.
+ LLVMContext Context;
+ std::unique_ptr<Module> M = makeLLVMModule(Context, ModuleString);
+ Function *F = M->getFunction(FuncName);
+
+ // Make the DTU.
+ DomTreeUpdater DTU(nullptr, nullptr, DomTreeUpdater::UpdateStrategy::Lazy);
+ ASSERT_FALSE(DTU.hasDomTree());
+ ASSERT_FALSE(DTU.hasPostDomTree());
+ Function::iterator FI = F->begin();
+ BasicBlock *BB0 = &*FI++;
+ // Test whether PendingDeletedBB is flushed after the recalculation.
+ DTU.deleteBB(BB0);
+ ASSERT_TRUE(DTU.hasPendingDeletedBB());
+ DTU.recalculate(*F);
+ ASSERT_FALSE(DTU.hasPendingDeletedBB());
+}
OpenPOWER on IntegriCloud