summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
diff options
context:
space:
mode:
authorChijun Sima <simachijun@gmail.com>2019-02-28 16:47:18 +0000
committerChijun Sima <simachijun@gmail.com>2019-02-28 16:47:18 +0000
commit586187639af23ec622598e1f97f2e514a5d91365 (patch)
tree472192a417e0d62f41609ee412251d5e914ac558 /llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
parent85c3afd7f6b1aca04f68f3dd1f88e3116d3c48c2 (diff)
downloadbcm5719-llvm-586187639af23ec622598e1f97f2e514a5d91365.tar.gz
bcm5719-llvm-586187639af23ec622598e1f97f2e514a5d91365.zip
Make MergeBlockIntoPredecessor conformant to the precondition of calling DTU.applyUpdates
Summary: It is mentioned in the document of DTU that "It is illegal to submit any update that has already been submitted, i.e., you are supposed not to insert an existent edge or delete a nonexistent edge." It is dangerous to violet this rule because DomTree and PostDomTree occasionally crash on this scenario. This patch fixes `MergeBlockIntoPredecessor`, making it conformant to this precondition. Reviewers: kuhar, brzycki, chandlerc Reviewed By: brzycki Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58444 llvm-svn: 355105
Diffstat (limited to 'llvm/lib/Transforms/Utils/BasicBlockUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/BasicBlockUtils.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index 0557b7d7442..81031b1a61e 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -186,7 +186,9 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU,
Updates.push_back({DominatorTree::Delete, PredBB, BB});
for (auto I = succ_begin(BB), E = succ_end(BB); I != E; ++I) {
Updates.push_back({DominatorTree::Delete, BB, *I});
- Updates.push_back({DominatorTree::Insert, PredBB, *I});
+ // This successor of BB may already have PredBB as a predecessor.
+ if (llvm::find(successors(PredBB), *I) == succ_end(PredBB))
+ Updates.push_back({DominatorTree::Insert, PredBB, *I});
}
}
OpenPOWER on IntegriCloud