[PATCH] D49731: [Dominators] Assert if there is modification to DelBB while it is awaiting deletion

Chijun Sima via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 24 10:00:35 PDT 2018


NutshellySima updated this revision to Diff 157067.
NutshellySima added a comment.

Address comments.


https://reviews.llvm.org/D49731

Files:
  include/llvm/IR/DomTreeUpdater.h
  lib/IR/DomTreeUpdater.cpp


Index: lib/IR/DomTreeUpdater.cpp
===================================================================
--- lib/IR/DomTreeUpdater.cpp
+++ lib/IR/DomTreeUpdater.cpp
@@ -136,6 +136,13 @@
     return false;
 
   for (auto *BB : DeletedBBs) {
+    // After calling deleteBB or callbackDeleteBB under Lazy UpdateStrategy,
+    // validateDeleteBB() removes all instructions of DelBB and adds an
+    // UnreachableInst as its terminator. So we check whether the BasicBlock to
+    // delete only has an UnreachableInst inside.
+    assert(BB->getInstList().size() == 1 &&
+           isa<UnreachableInst>(BB->getTerminator()) &&
+           "DelBB has been modified while awaiting deletion.");
     BB->removeFromParent();
     eraseDelBBNode(BB);
     delete BB;
Index: include/llvm/IR/DomTreeUpdater.h
===================================================================
--- include/llvm/IR/DomTreeUpdater.h
+++ include/llvm/IR/DomTreeUpdater.h
@@ -143,17 +143,19 @@
   /// erased from available trees if it exists and finally get deleted.
   /// Under Eager UpdateStrategy, DelBB will be processed immediately.
   /// Under Lazy UpdateStrategy, DelBB will be queued until a flush event and
-  /// all available trees are up-to-date. When both DT and PDT are nullptrs,
-  /// DelBB will be queued until flush() is called.
+  /// all available trees are up-to-date. Assert if any instruction of DelBB is
+  /// modified while awaiting deletion. When both DT and PDT are nullptrs, DelBB
+  /// will be queued until flush() is called.
   void deleteBB(BasicBlock *DelBB);
 
   /// Delete DelBB. DelBB will be removed from its Parent and
   /// erased from available trees if it exists. Then the callback will
   /// be called. Finally, DelBB will be deleted.
   /// Under Eager UpdateStrategy, DelBB will be processed immediately.
   /// Under Lazy UpdateStrategy, DelBB will be queued until a flush event and
-  /// all available trees are up-to-date.
-  /// Multiple callbacks can be queued for one DelBB under Lazy UpdateStrategy.
+  /// all available trees are up-to-date. Assert if any instruction of DelBB is
+  /// modified while awaiting deletion. Multiple callbacks can be queued for one
+  /// DelBB under Lazy UpdateStrategy.
   void callbackDeleteBB(BasicBlock *DelBB,
                         std::function<void(BasicBlock *)> Callback);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49731.157067.patch
Type: text/x-patch
Size: 2343 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180724/f16aa056/attachment.bin>


More information about the llvm-commits mailing list