summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DomTreeUpdater.cpp
diff options
context:
space:
mode:
authorChijun Sima <simachijun@gmail.com>2018-07-25 06:18:33 +0000
committerChijun Sima <simachijun@gmail.com>2018-07-25 06:18:33 +0000
commitbd5d80d050567c9f9a84e32e46f02496958c414e (patch)
treefa727795cd71d6372cb1b138480306102e850da5 /llvm/lib/IR/DomTreeUpdater.cpp
parentdc0e8a601dae520e6f05cd18b7dc88b6aaf9ebe1 (diff)
downloadbcm5719-llvm-bd5d80d050567c9f9a84e32e46f02496958c414e.tar.gz
bcm5719-llvm-bd5d80d050567c9f9a84e32e46f02496958c414e.zip
[Dominators] Assert if there is modification to DelBB while it is awaiting deletion
Summary: Previously, passes use ``` DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy); DTU.deleteBB(DelBB); ``` to delete a BasicBlock. But passes which don't have the ability to update DomTree (e.g. tailcallelim, simplifyCFG) cannot recognize a DelBB awaiting deletion and will continue to process this DelBB. This is a simple approach to notify devs of passes which may use DTU in the future to deal with deleted BasicBlocks under Lazy Strategy correctly. Reviewers: kuhar, brzycki, dmgreen Reviewed By: kuhar Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49731 llvm-svn: 337891
Diffstat (limited to 'llvm/lib/IR/DomTreeUpdater.cpp')
-rw-r--r--llvm/lib/IR/DomTreeUpdater.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/IR/DomTreeUpdater.cpp b/llvm/lib/IR/DomTreeUpdater.cpp
index 9af22b16224..f035a86edda 100644
--- a/llvm/lib/IR/DomTreeUpdater.cpp
+++ b/llvm/lib/IR/DomTreeUpdater.cpp
@@ -136,6 +136,13 @@ bool DomTreeUpdater::forceFlushDeletedBB() {
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;
OpenPOWER on IntegriCloud