diff --git a/llvm/include/llvm/IR/CFGDiff.h b/llvm/include/llvm/IR/CFGDiff.h --- a/llvm/include/llvm/IR/CFGDiff.h +++ b/llvm/include/llvm/IR/CFGDiff.h @@ -155,23 +155,26 @@ #endif }; -template struct CFGViewSuccessors { - using DataRef = const GraphDiff *; +template > +struct CFGViewSuccessors { + using DataRef = const GraphDiff *; + using RawNodeRef = typename GT::NodeRef; using NodeRef = std::pair; using ExistingChildIterator = - WrappedPairNodeDataIterator; + WrappedPairNodeDataIterator; struct DeletedEdgesFilter { - BasicBlock *BB; - DeletedEdgesFilter(BasicBlock *BB) : BB(BB){}; + RawNodeRef BB; + DeletedEdgesFilter(RawNodeRef BB) : BB(BB){}; bool operator()(NodeRef N) const { - return !N.first->ignoreChild(BB, N.second, false); + return !N.first->ignoreChild(BB, N.second, InverseEdge); } }; using FilterExistingChildrenIterator = filter_iterator; - using vec_iterator = SmallVectorImpl::const_iterator; + using vec_iterator = typename SmallVectorImpl::const_iterator; using AddNewChildrenIterator = WrappedPairNodeDataIterator; using ChildIteratorType = @@ -179,11 +182,11 @@ AddNewChildrenIterator>; static ChildIteratorType child_begin(NodeRef N) { - auto InsertVec = N.first->getAddedChildren(N.second, false); + auto InsertVec = N.first->getAddedChildren(N.second, InverseEdge); // filter iterator init: auto firstit = make_filter_range( - make_range({succ_begin(N.second), N.first}, - {succ_end(N.second), N.first}), + 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( @@ -194,11 +197,11 @@ } static ChildIteratorType child_end(NodeRef N) { - auto InsertVec = N.first->getAddedChildren(N.second, false); + auto InsertVec = N.first->getAddedChildren(N.second, InverseEdge); // filter iterator init: auto firstit = make_filter_range( - make_range({succ_end(N.second), N.first}, - {succ_end(N.second), N.first}), + 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( @@ -209,76 +212,14 @@ } }; -template struct CFGViewPredecessors { - using DataRef = const GraphDiff *; - using NodeRef = std::pair; - - using ExistingChildIterator = - WrappedPairNodeDataIterator; - struct DeletedEdgesFilter { - BasicBlock *BB; - DeletedEdgesFilter(BasicBlock *BB) : BB(BB){}; - bool operator()(NodeRef N) const { - return !N.first->ignoreChild(BB, N.second, true); - } - }; - using FilterExistingChildrenIterator = - filter_iterator; - - using vec_iterator = SmallVectorImpl::const_iterator; - using AddNewChildrenIterator = - WrappedPairNodeDataIterator; - using ChildIteratorType = - concat_iterator; - - static ChildIteratorType child_begin(NodeRef N) { - auto InsertVec = N.first->getAddedChildren(N.second, true); - // filter iterator init: - auto firstit = make_filter_range( - make_range({pred_begin(N.second), N.first}, - {pred_end(N.second), N.first}), - DeletedEdgesFilter(N.second)); - // new inserts iterator init: - auto secondit = make_range( - {InsertVec.begin(), N.first}, {InsertVec.end(), N.first}); - - return concat_iterator(firstit, secondit); - } - - static ChildIteratorType child_end(NodeRef N) { - auto InsertVec = N.first->getAddedChildren(N.second, true); - // filter iterator init: - auto firstit = make_filter_range( - make_range({pred_end(N.second), N.first}, - {pred_end(N.second), N.first}), - DeletedEdgesFilter(N.second)); - // new inserts iterator init: - auto secondit = make_range( - {InsertVec.end(), N.first}, {InsertVec.end(), N.first}); - - return concat_iterator(firstit, secondit); - } -}; - -template <> -struct GraphTraits< - std::pair *, BasicBlock *>> - : CFGViewSuccessors {}; -template <> -struct GraphTraits< - std::pair *, BasicBlock *>> - : CFGViewSuccessors {}; -template <> +template struct GraphTraits< - std::pair *, Inverse>> - : CFGViewPredecessors {}; -template <> + std::pair *, T>> + : CFGViewSuccessors {}; +template struct GraphTraits< - std::pair *, Inverse>> - : CFGViewPredecessors {}; + std::pair *, Inverse>> + : CFGViewSuccessors, B, true> {}; } // end namespace llvm #endif // LLVM_IR_CFGDIFF_H