[PATCH] D35571: [Dominators] Improve error checking in deleteEdge
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 11:14:56 PDT 2017
This is O(N), so you may want to do it only #ifndef NDEBUG
On Tue, Jul 18, 2017 at 10:37 AM, Jakub Kuderski via Phabricator <
reviews at reviews.llvm.org> wrote:
> kuhar created this revision.
>
> 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.
>
>
> https://reviews.llvm.org/D35571
>
> Files:
> include/llvm/Support/GenericDomTreeConstruction.h
>
>
> Index: include/llvm/Support/GenericDomTreeConstruction.h
> ===================================================================
> --- include/llvm/Support/GenericDomTreeConstruction.h
> +++ include/llvm/Support/GenericDomTreeConstruction.h
> @@ -569,11 +569,22 @@
> assert(From && To && "Cannot disconnect nullptrs");
> DEBUG(dbgs() << "Deleting edge " << BlockNamePrinter(From) << " -> "
> << BlockNamePrinter(To) << "\n");
> +
> + // Ensure that the edge was in fact deleted from the CFG before
> informing
> + // the DomTree about it.
> + 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!");
> +
> 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);
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170718/e8600686/attachment.html>
More information about the llvm-commits
mailing list