diff options
| author | Chijun Sima <simachijun@gmail.com> | 2018-08-03 12:45:29 +0000 |
|---|---|---|
| committer | Chijun Sima <simachijun@gmail.com> | 2018-08-03 12:45:29 +0000 |
| commit | 530484372b95406b12a12616857df8bc268f83c1 (patch) | |
| tree | 05d0d95441fed1973489b1b419aeca1655aa80c5 /llvm/unittests | |
| parent | eaca8ed5b8e7f790e8536b2ec013239439c010a0 (diff) | |
| download | bcm5719-llvm-530484372b95406b12a12616857df8bc268f83c1.tar.gz bcm5719-llvm-530484372b95406b12a12616857df8bc268f83c1.zip | |
[Dominators] Make RemoveUnreachableBlocks return false if the BasicBlock is already awaiting deletion
Summary:
Previously, `removeUnreachableBlocks` still returns true (which indicates the CFG is changed) even when all the unreachable blocks found is awaiting deletion in the DDT class.
This makes code pattern like
```
// Code modified from lib/Transforms/Scalar/SimplifyCFGPass.cpp
bool EverChanged = removeUnreachableBlocks(F, nullptr, DDT);
...
do {
EverChanged = someMightHappenModifications();
EverChanged |= removeUnreachableBlocks(F, nullptr, DDT);
} while (EverChanged);
```
become a dead loop.
Fix this by detecting whether a BasicBlock is already awaiting deletion.
Reviewers: kuhar, brzycki, dmgreen, grosser, davide
Reviewed By: kuhar, brzycki
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D49738
llvm-svn: 338882
Diffstat (limited to 'llvm/unittests')
| -rw-r--r-- | llvm/unittests/Transforms/Utils/Local.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/unittests/Transforms/Utils/Local.cpp b/llvm/unittests/Transforms/Utils/Local.cpp index 312c32e38ac..53cfc6b4a34 100644 --- a/llvm/unittests/Transforms/Utils/Local.cpp +++ b/llvm/unittests/Transforms/Utils/Local.cpp @@ -844,4 +844,23 @@ TEST(Local, RemoveUnreachableBlocks) { runWithDomTree(*M, "br_self_loop", runLazy); runWithDomTree(*M, "br_constant", runLazy); runWithDomTree(*M, "br_loop", runLazy); + + M = parseIR(C, + R"( + define void @f() { + entry: + ret void + bb0: + ret void + } + )"); + + auto checkRUBlocksRetVal = [&](Function &F, DominatorTree *DT) { + DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy); + EXPECT_TRUE(removeUnreachableBlocks(F, nullptr, &DTU)); + EXPECT_FALSE(removeUnreachableBlocks(F, nullptr, &DTU)); + EXPECT_TRUE(DTU.getDomTree().verify()); + }; + + runWithDomTree(*M, "f", checkRUBlocksRetVal); }
\ No newline at end of file |

