From 09d2d2b02c63883b34d924aa40f916c35f2541c5 Mon Sep 17 00:00:00 2001 From: Adrian Kuegel Date: Thu, 19 Mar 2020 11:22:16 +0100 Subject: [PATCH] Revert "CFGDiff: Simplify/common the begin/end implementations to use a common range helper" This reverts commit 79a7ed92a9b135212a6a271dd8dbc625038c8f06. This breaks the asan buildbot. --- include/llvm/IR/CFGDiff.h | 70 ++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/include/llvm/IR/CFGDiff.h b/include/llvm/IR/CFGDiff.h index a140fcb3958..f40434cc5d4 100644 --- a/include/llvm/IR/CFGDiff.h +++ b/include/llvm/IR/CFGDiff.h @@ -158,42 +158,58 @@ template > struct CFGViewChildren { using DataRef = const GraphDiff *; - using NodeRef = std::pair; + using RawNodeRef = typename GT::NodeRef; + using NodeRef = std::pair; - template - static auto makeChildRange(Range &&R, DataRef DR) { - using Iter = WrappedPairNodeDataIterator(R).begin()), NodeRef, DataRef>; - return make_range(Iter(R.begin(), DR), Iter(R.end(), DR)); - } + using ExistingChildIterator = + WrappedPairNodeDataIterator; + struct DeletedEdgesFilter { + RawNodeRef BB; + DeletedEdgesFilter(RawNodeRef BB) : BB(BB){}; + bool operator()(NodeRef N) const { + return !N.first->ignoreChild(BB, N.second, InverseEdge); + } + }; + using FilterExistingChildrenIterator = + filter_iterator; - static auto children(NodeRef N) { + using vec_iterator = typename SmallVectorImpl::const_iterator; + using AddNewChildrenIterator = + WrappedPairNodeDataIterator; + using ChildIteratorType = + concat_iterator; - // filter iterator init: - auto R = make_range(GT::child_begin(N.second), GT::child_end(N.second)); - auto First = make_filter_range(makeChildRange(R, N.first), [&](NodeRef C) { - return !C.first->ignoreChild(N.second, C.second, InverseEdge); - }); - - // new inserts iterator init: + static ChildIteratorType child_begin(NodeRef N) { auto InsertVec = N.first->getAddedChildren(N.second, InverseEdge); - auto Second = makeChildRange(InsertVec, N.first); + // filter iterator init: + auto firstit = make_filter_range( + make_range({GT::child_begin(N.second), N.first}, + {GT::child_end(N.second), N.first}), + DeletedEdgesFilter(N.second)); + // new inserts iterator init: + auto secondit = make_range( + {InsertVec.begin(), N.first}, {InsertVec.end(), N.first}); - auto CR = concat(First, Second); - // concat_range contains references to other ranges, returning it would - // leave those references dangling - the iterators contain - // other iterators by value so they're safe to return. - return make_range(CR.begin(), CR.end()); + return concat_iterator(firstit, secondit); } - static auto child_begin(NodeRef N) { - return children(N).begin(); - } + static ChildIteratorType child_end(NodeRef N) { + auto InsertVec = N.first->getAddedChildren(N.second, InverseEdge); + // filter iterator init: + auto firstit = make_filter_range( + make_range({GT::child_end(N.second), N.first}, + {GT::child_end(N.second), N.first}), + DeletedEdgesFilter(N.second)); + // new inserts iterator init: + auto secondit = make_range( + {InsertVec.end(), N.first}, {InsertVec.end(), N.first}); - static auto child_end(NodeRef N) { - return children(N).end(); + return concat_iterator(firstit, secondit); } - - using ChildIteratorType = decltype(child_end(std::declval())); }; template