[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
Thu Aug 2 08:57:13 PDT 2018
NutshellySima updated this revision to Diff 158772.
NutshellySima added a comment.
Address comments.
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
@@ -838,4 +838,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:
+ 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
Index: lib/Transforms/Utils/Local.cpp
===================================================================
--- lib/Transforms/Utils/Local.cpp
+++ lib/Transforms/Utils/Local.cpp
@@ -2265,8 +2265,16 @@
if (DTU) {
DTU->applyUpdates(Updates, /*ForceRemoveDuplicates*/ 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.158772.patch
Type: text/x-patch
Size: 1471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180802/6f29a26b/attachment.bin>
More information about the llvm-commits
mailing list