diff options
author | Vedant Kumar <vsk@apple.com> | 2020-02-20 14:16:25 -0800 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2020-02-20 16:41:51 -0800 |
commit | 7593a480dbce4e26f7dda4aa8f15bffd03acbfdb (patch) | |
tree | 546b7a58c183d33c34df325e0c6e9056f9088e51 /llvm/unittests/IR/DominatorTreeTest.cpp | |
parent | 2fe457690da0fc38bc7f9f1d0aee2ba6a6a16ada (diff) | |
download | llvm-7593a480dbce4e26f7dda4aa8f15bffd03acbfdb.zip llvm-7593a480dbce4e26f7dda4aa8f15bffd03acbfdb.tar.gz llvm-7593a480dbce4e26f7dda4aa8f15bffd03acbfdb.tar.bz2 |
[Dominators] Use Instruction::comesBefore for block-local queries, NFC
Use the lazy instruction ordering facility for block-local dominance
queries.
Differential Revision: https://reviews.llvm.org/D74931
Diffstat (limited to 'llvm/unittests/IR/DominatorTreeTest.cpp')
-rw-r--r-- | llvm/unittests/IR/DominatorTreeTest.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/llvm/unittests/IR/DominatorTreeTest.cpp b/llvm/unittests/IR/DominatorTreeTest.cpp index 7773856..22d2003 100644 --- a/llvm/unittests/IR/DominatorTreeTest.cpp +++ b/llvm/unittests/IR/DominatorTreeTest.cpp @@ -43,6 +43,37 @@ static std::unique_ptr<Module> makeLLVMModule(LLVMContext &Context, return M; } +TEST(DominatorTree, PHIs) { + StringRef ModuleString = R"( + define void @f() { + bb1: + br label %bb1 + bb2: + %a = phi i32 [0, %bb1], [1, %bb2] + %b = phi i32 [2, %bb1], [%a, %bb2] + br label %bb2 + }; + )"; + + // Parse the module. + LLVMContext Context; + std::unique_ptr<Module> M = makeLLVMModule(Context, ModuleString); + + runWithDomTree(*M, "f", + [&](Function &F, DominatorTree *DT, PostDominatorTree *PDT) { + auto FI = F.begin(); + ++FI; + BasicBlock *BB2 = &*FI; + auto BI = BB2->begin(); + Instruction *PhiA = &*BI++; + Instruction *PhiB = &*BI; + + // Phis are thought to execute "instantly, together". + EXPECT_TRUE(DT->dominates(PhiA, PhiB)); + EXPECT_TRUE(DT->dominates(PhiB, PhiA)); + }); +} + TEST(DominatorTree, Unreachable) { StringRef ModuleString = "declare i32 @g()\n" |