[PATCH] D58444: Make MergeBlockIntoPredecessor conformant to the precondition of calling DTU.applyUpdates
Chijun Sima via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 20 05:55:21 PST 2019
NutshellySima created this revision.
NutshellySima added reviewers: kuhar, brzycki, chandlerc.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D58444
Files:
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
Index: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
===================================================================
--- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -186,7 +186,9 @@
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});
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58444.187559.patch
Type: text/x-patch
Size: 711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190220/2b7d7840/attachment.bin>
More information about the llvm-commits
mailing list