[llvm] r308354 - [Dominators] Improve error checking in deleteEdge
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 13:19:52 PDT 2017
Author: kuhar
Date: Tue Jul 18 13:19:52 2017
New Revision: 308354
URL: http://llvm.org/viewvc/llvm-project?rev=308354&view=rev
Log:
[Dominators] Improve error checking in deleteEdge
Summary: This patch improves error detection in deleteEdge. It asserts that the edge doesn't exist in the CFG and that DomTree knew about this edge before.
Reviewers: dberlin, grosser, brzycki, sanjoy
Reviewed By: dberlin
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D35571
Modified:
llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h
Modified: llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h?rev=308354&r1=308353&r2=308354&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h (original)
+++ llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h Tue Jul 18 13:19:52 2017
@@ -569,11 +569,25 @@ struct SemiNCAInfo {
assert(From && To && "Cannot disconnect nullptrs");
DEBUG(dbgs() << "Deleting edge " << BlockNamePrinter(From) << " -> "
<< BlockNamePrinter(To) << "\n");
+
+#ifndef NDEBUG
+ // Ensure that the edge was in fact deleted from the CFG before informing
+ // the DomTree about it.
+ // The check is O(N), so run it only in debug configuration.
+ auto IsSuccessor = [](const NodePtr SuccCandidate, const NodePtr Of) {
+ auto Successors = ChildrenGetter<NodePtr, IsPostDom>::Get(Of);
+ return llvm::find(Successors, SuccCandidate) != Successors.end();
+ };
+ (void)IsSuccessor;
+ assert(!IsSuccessor(To, From) && "Deleted edge still exists in the CFG!");
+#endif
+
const TreeNodePtr FromTN = DT.getNode(From);
// Deletion in an unreachable subtree -- nothing to do.
if (!FromTN) return;
const TreeNodePtr ToTN = DT.getNode(To);
+ assert(ToTN && "To already unreachable -- there is no edge to delete");
const NodePtr NCDBlock = DT.findNearestCommonDominator(From, To);
const TreeNodePtr NCD = DT.getNode(NCDBlock);
More information about the llvm-commits
mailing list