[PATCH] D49738: [Dominators] Make RemoveUnreachableBlocks return false if the BasicBlock is already awaiting deletion
Chijun Sima via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 24 10:12:55 PDT 2018
NutshellySima updated this revision to Diff 157069.
NutshellySima added a comment.
Rebase to use the DomTreeUpdater interface.
https://reviews.llvm.org/D49738
Files:
lib/Transforms/Utils/Local.cpp
unittests/Transforms/Utils/Local.cpp
Index: unittests/Transforms/Utils/Local.cpp
===================================================================
--- unittests/Transforms/Utils/Local.cpp
+++ unittests/Transforms/Utils/Local.cpp
@@ -744,4 +744,23 @@
runWithDomTree(*M, "br_self_loop", runLazy);
runWithDomTree(*M, "br_constant", runLazy);
runWithDomTree(*M, "br_loop", runLazy);
+
+ M = parseIR(C,
+ R"(
+ define void @f() {
+ entry:
+ br label %entry
+ 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
Index: lib/Transforms/Utils/Local.cpp
===================================================================
--- lib/Transforms/Utils/Local.cpp
+++ lib/Transforms/Utils/Local.cpp
@@ -2260,8 +2260,16 @@
if (DTU) {
DTU->applyUpdates(Updates, /*ForceDeduplication*/ true);
- for (auto *BB : ToDeleteBBs)
+ bool Deleted = false;
+ for (auto *BB : ToDeleteBBs) {
+ if (DTU->isBBPendingDeletion(BB))
+ --NumRemoved;
+ else
+ Deleted = true;
DTU->deleteBB(BB);
+ }
+ if (!Deleted)
+ return false;
}
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49738.157069.patch
Type: text/x-patch
Size: 1475 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180724/cf5283b1/attachment.bin>
More information about the llvm-commits
mailing list