llvm.org GIT mirror llvm / 9580103
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308354 91177308-0d34-0410-b5e6-96231b3b80d8 Jakub Kuderski 3 years ago
1 changed file(s) with 14 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
568568 assert(From && To && "Cannot disconnect nullptrs");
569569 DEBUG(dbgs() << "Deleting edge " << BlockNamePrinter(From) << " -> "
570570 << BlockNamePrinter(To) << "\n");
571
572 #ifndef NDEBUG
573 // Ensure that the edge was in fact deleted from the CFG before informing
574 // the DomTree about it.
575 // The check is O(N), so run it only in debug configuration.
576 auto IsSuccessor = [](const NodePtr SuccCandidate, const NodePtr Of) {
577 auto Successors = ChildrenGetter::Get(Of);
578 return llvm::find(Successors, SuccCandidate) != Successors.end();
579 };
580 (void)IsSuccessor;
581 assert(!IsSuccessor(To, From) && "Deleted edge still exists in the CFG!");
582 #endif
583
571584 const TreeNodePtr FromTN = DT.getNode(From);
572585 // Deletion in an unreachable subtree -- nothing to do.
573586 if (!FromTN) return;
574587
575588 const TreeNodePtr ToTN = DT.getNode(To);
589 assert(ToTN && "To already unreachable -- there is no edge to delete");
576590 const NodePtr NCDBlock = DT.findNearestCommonDominator(From, To);
577591 const TreeNodePtr NCD = DT.getNode(NCDBlock);
578592