10b57cec5SDimitry Andric //===--- DAGDeltaAlgorithm.cpp - A DAG Minimization Algorithm --*- C++ -*--===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
70b57cec5SDimitry Andric //
80b57cec5SDimitry Andric // The algorithm we use attempts to exploit the dependency information by
90b57cec5SDimitry Andric // minimizing top-down. We start by constructing an initial root set R, and
100b57cec5SDimitry Andric // then iteratively:
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric // 1. Minimize the set R using the test predicate:
130b57cec5SDimitry Andric // P'(S) = P(S union pred*(S))
140b57cec5SDimitry Andric //
150b57cec5SDimitry Andric // 2. Extend R to R' = R union pred(R).
160b57cec5SDimitry Andric //
170b57cec5SDimitry Andric // until a fixed point is reached.
180b57cec5SDimitry Andric //
190b57cec5SDimitry Andric // The idea is that we want to quickly prune entire portions of the graph, so we
200b57cec5SDimitry Andric // try to find high-level nodes that can be eliminated with all of their
210b57cec5SDimitry Andric // dependents.
220b57cec5SDimitry Andric //
230b57cec5SDimitry Andric // FIXME: The current algorithm doesn't actually provide a strong guarantee
240b57cec5SDimitry Andric // about the minimality of the result. The problem is that after adding nodes to
250b57cec5SDimitry Andric // the required set, we no longer consider them for elimination. For strictly
260b57cec5SDimitry Andric // well formed predicates, this doesn't happen, but it commonly occurs in
270b57cec5SDimitry Andric // practice when there are unmodelled dependencies. I believe we can resolve
280b57cec5SDimitry Andric // this by allowing the required set to be minimized as well, but need more test
290b57cec5SDimitry Andric // cases first.
300b57cec5SDimitry Andric //
310b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
320b57cec5SDimitry Andric
330b57cec5SDimitry Andric #include "llvm/ADT/DAGDeltaAlgorithm.h"
340b57cec5SDimitry Andric #include "llvm/ADT/DeltaAlgorithm.h"
350b57cec5SDimitry Andric #include "llvm/Support/Debug.h"
360b57cec5SDimitry Andric #include "llvm/Support/Format.h"
370b57cec5SDimitry Andric #include "llvm/Support/raw_ostream.h"
380b57cec5SDimitry Andric #include <algorithm>
390b57cec5SDimitry Andric #include <cassert>
400b57cec5SDimitry Andric #include <map>
410b57cec5SDimitry Andric using namespace llvm;
420b57cec5SDimitry Andric
430b57cec5SDimitry Andric #define DEBUG_TYPE "dag-delta"
440b57cec5SDimitry Andric
450b57cec5SDimitry Andric namespace {
460b57cec5SDimitry Andric
470b57cec5SDimitry Andric class DAGDeltaAlgorithmImpl {
480b57cec5SDimitry Andric friend class DeltaActiveSetHelper;
490b57cec5SDimitry Andric
500b57cec5SDimitry Andric public:
510b57cec5SDimitry Andric typedef DAGDeltaAlgorithm::change_ty change_ty;
520b57cec5SDimitry Andric typedef DAGDeltaAlgorithm::changeset_ty changeset_ty;
530b57cec5SDimitry Andric typedef DAGDeltaAlgorithm::changesetlist_ty changesetlist_ty;
540b57cec5SDimitry Andric typedef DAGDeltaAlgorithm::edge_ty edge_ty;
550b57cec5SDimitry Andric
560b57cec5SDimitry Andric private:
570b57cec5SDimitry Andric typedef std::vector<change_ty>::iterator pred_iterator_ty;
580b57cec5SDimitry Andric typedef std::vector<change_ty>::iterator succ_iterator_ty;
590b57cec5SDimitry Andric typedef std::set<change_ty>::iterator pred_closure_iterator_ty;
600b57cec5SDimitry Andric typedef std::set<change_ty>::iterator succ_closure_iterator_ty;
610b57cec5SDimitry Andric
620b57cec5SDimitry Andric DAGDeltaAlgorithm &DDA;
630b57cec5SDimitry Andric
640b57cec5SDimitry Andric std::vector<change_ty> Roots;
650b57cec5SDimitry Andric
660b57cec5SDimitry Andric /// Cache of failed test results. Successful test results are never cached
670b57cec5SDimitry Andric /// since we always reduce following a success. We maintain an independent
680b57cec5SDimitry Andric /// cache from that used by the individual delta passes because we may get
690b57cec5SDimitry Andric /// hits across multiple individual delta invocations.
700b57cec5SDimitry Andric mutable std::set<changeset_ty> FailedTestsCache;
710b57cec5SDimitry Andric
720b57cec5SDimitry Andric // FIXME: Gross.
730b57cec5SDimitry Andric std::map<change_ty, std::vector<change_ty> > Predecessors;
740b57cec5SDimitry Andric std::map<change_ty, std::vector<change_ty> > Successors;
750b57cec5SDimitry Andric
760b57cec5SDimitry Andric std::map<change_ty, std::set<change_ty> > PredClosure;
770b57cec5SDimitry Andric std::map<change_ty, std::set<change_ty> > SuccClosure;
780b57cec5SDimitry Andric
790b57cec5SDimitry Andric private:
pred_begin(change_ty Node)800b57cec5SDimitry Andric pred_iterator_ty pred_begin(change_ty Node) {
810b57cec5SDimitry Andric assert(Predecessors.count(Node) && "Invalid node!");
820b57cec5SDimitry Andric return Predecessors[Node].begin();
830b57cec5SDimitry Andric }
pred_end(change_ty Node)840b57cec5SDimitry Andric pred_iterator_ty pred_end(change_ty Node) {
850b57cec5SDimitry Andric assert(Predecessors.count(Node) && "Invalid node!");
860b57cec5SDimitry Andric return Predecessors[Node].end();
870b57cec5SDimitry Andric }
880b57cec5SDimitry Andric
pred_closure_begin(change_ty Node)890b57cec5SDimitry Andric pred_closure_iterator_ty pred_closure_begin(change_ty Node) {
900b57cec5SDimitry Andric assert(PredClosure.count(Node) && "Invalid node!");
910b57cec5SDimitry Andric return PredClosure[Node].begin();
920b57cec5SDimitry Andric }
pred_closure_end(change_ty Node)930b57cec5SDimitry Andric pred_closure_iterator_ty pred_closure_end(change_ty Node) {
940b57cec5SDimitry Andric assert(PredClosure.count(Node) && "Invalid node!");
950b57cec5SDimitry Andric return PredClosure[Node].end();
960b57cec5SDimitry Andric }
970b57cec5SDimitry Andric
succ_begin(change_ty Node)980b57cec5SDimitry Andric succ_iterator_ty succ_begin(change_ty Node) {
990b57cec5SDimitry Andric assert(Successors.count(Node) && "Invalid node!");
1000b57cec5SDimitry Andric return Successors[Node].begin();
1010b57cec5SDimitry Andric }
succ_end(change_ty Node)1020b57cec5SDimitry Andric succ_iterator_ty succ_end(change_ty Node) {
1030b57cec5SDimitry Andric assert(Successors.count(Node) && "Invalid node!");
1040b57cec5SDimitry Andric return Successors[Node].end();
1050b57cec5SDimitry Andric }
1060b57cec5SDimitry Andric
succ_closure_begin(change_ty Node)1070b57cec5SDimitry Andric succ_closure_iterator_ty succ_closure_begin(change_ty Node) {
1080b57cec5SDimitry Andric assert(SuccClosure.count(Node) && "Invalid node!");
1090b57cec5SDimitry Andric return SuccClosure[Node].begin();
1100b57cec5SDimitry Andric }
succ_closure_end(change_ty Node)1110b57cec5SDimitry Andric succ_closure_iterator_ty succ_closure_end(change_ty Node) {
1120b57cec5SDimitry Andric assert(SuccClosure.count(Node) && "Invalid node!");
1130b57cec5SDimitry Andric return SuccClosure[Node].end();
1140b57cec5SDimitry Andric }
1150b57cec5SDimitry Andric
UpdatedSearchState(const changeset_ty & Changes,const changesetlist_ty & Sets,const changeset_ty & Required)1160b57cec5SDimitry Andric void UpdatedSearchState(const changeset_ty &Changes,
1170b57cec5SDimitry Andric const changesetlist_ty &Sets,
1180b57cec5SDimitry Andric const changeset_ty &Required) {
1190b57cec5SDimitry Andric DDA.UpdatedSearchState(Changes, Sets, Required);
1200b57cec5SDimitry Andric }
1210b57cec5SDimitry Andric
1220b57cec5SDimitry Andric /// ExecuteOneTest - Execute a single test predicate on the change set \p S.
ExecuteOneTest(const changeset_ty & S)1230b57cec5SDimitry Andric bool ExecuteOneTest(const changeset_ty &S) {
1240b57cec5SDimitry Andric // Check dependencies invariant.
1250b57cec5SDimitry Andric LLVM_DEBUG({
1260b57cec5SDimitry Andric for (changeset_ty::const_iterator it = S.begin(), ie = S.end(); it != ie;
1270b57cec5SDimitry Andric ++it)
1280b57cec5SDimitry Andric for (succ_iterator_ty it2 = succ_begin(*it), ie2 = succ_end(*it);
1290b57cec5SDimitry Andric it2 != ie2; ++it2)
1300b57cec5SDimitry Andric assert(S.count(*it2) && "Attempt to run invalid changeset!");
1310b57cec5SDimitry Andric });
1320b57cec5SDimitry Andric
1330b57cec5SDimitry Andric return DDA.ExecuteOneTest(S);
1340b57cec5SDimitry Andric }
1350b57cec5SDimitry Andric
1360b57cec5SDimitry Andric public:
1370b57cec5SDimitry Andric DAGDeltaAlgorithmImpl(DAGDeltaAlgorithm &DDA, const changeset_ty &Changes,
1380b57cec5SDimitry Andric const std::vector<edge_ty> &Dependencies);
1390b57cec5SDimitry Andric
1400b57cec5SDimitry Andric changeset_ty Run();
1410b57cec5SDimitry Andric
1420b57cec5SDimitry Andric /// GetTestResult - Get the test result for the active set \p Changes with
1430b57cec5SDimitry Andric /// \p Required changes from the cache, executing the test if necessary.
1440b57cec5SDimitry Andric ///
1450b57cec5SDimitry Andric /// \param Changes - The set of active changes being minimized, which should
1460b57cec5SDimitry Andric /// have their pred closure included in the test.
1470b57cec5SDimitry Andric /// \param Required - The set of changes which have previously been
1480b57cec5SDimitry Andric /// established to be required.
1490b57cec5SDimitry Andric /// \return - The test result.
1500b57cec5SDimitry Andric bool GetTestResult(const changeset_ty &Changes, const changeset_ty &Required);
1510b57cec5SDimitry Andric };
1520b57cec5SDimitry Andric
1530b57cec5SDimitry Andric /// Helper object for minimizing an active set of changes.
1540b57cec5SDimitry Andric class DeltaActiveSetHelper : public DeltaAlgorithm {
1550b57cec5SDimitry Andric DAGDeltaAlgorithmImpl &DDAI;
1560b57cec5SDimitry Andric
1570b57cec5SDimitry Andric const changeset_ty &Required;
1580b57cec5SDimitry Andric
1590b57cec5SDimitry Andric protected:
1600b57cec5SDimitry Andric /// UpdatedSearchState - Callback used when the search state changes.
UpdatedSearchState(const changeset_ty & Changes,const changesetlist_ty & Sets)1610b57cec5SDimitry Andric void UpdatedSearchState(const changeset_ty &Changes,
1620b57cec5SDimitry Andric const changesetlist_ty &Sets) override {
1630b57cec5SDimitry Andric DDAI.UpdatedSearchState(Changes, Sets, Required);
1640b57cec5SDimitry Andric }
1650b57cec5SDimitry Andric
ExecuteOneTest(const changeset_ty & S)1660b57cec5SDimitry Andric bool ExecuteOneTest(const changeset_ty &S) override {
1670b57cec5SDimitry Andric return DDAI.GetTestResult(S, Required);
1680b57cec5SDimitry Andric }
1690b57cec5SDimitry Andric
1700b57cec5SDimitry Andric public:
DeltaActiveSetHelper(DAGDeltaAlgorithmImpl & DDAI,const changeset_ty & Required)1710b57cec5SDimitry Andric DeltaActiveSetHelper(DAGDeltaAlgorithmImpl &DDAI,
1720b57cec5SDimitry Andric const changeset_ty &Required)
1730b57cec5SDimitry Andric : DDAI(DDAI), Required(Required) {}
1740b57cec5SDimitry Andric };
1750b57cec5SDimitry Andric
176fe6060f1SDimitry Andric } // namespace
1770b57cec5SDimitry Andric
DAGDeltaAlgorithmImpl(DAGDeltaAlgorithm & DDA,const changeset_ty & Changes,const std::vector<edge_ty> & Dependencies)1780b57cec5SDimitry Andric DAGDeltaAlgorithmImpl::DAGDeltaAlgorithmImpl(
1790b57cec5SDimitry Andric DAGDeltaAlgorithm &DDA, const changeset_ty &Changes,
1800b57cec5SDimitry Andric const std::vector<edge_ty> &Dependencies)
1810b57cec5SDimitry Andric : DDA(DDA) {
182*0eae32dcSDimitry Andric for (change_ty Change : Changes) {
183*0eae32dcSDimitry Andric Predecessors.insert(std::make_pair(Change, std::vector<change_ty>()));
184*0eae32dcSDimitry Andric Successors.insert(std::make_pair(Change, std::vector<change_ty>()));
1850b57cec5SDimitry Andric }
186*0eae32dcSDimitry Andric for (const edge_ty &Dep : Dependencies) {
187*0eae32dcSDimitry Andric Predecessors[Dep.second].push_back(Dep.first);
188*0eae32dcSDimitry Andric Successors[Dep.first].push_back(Dep.second);
1890b57cec5SDimitry Andric }
1900b57cec5SDimitry Andric
1910b57cec5SDimitry Andric // Compute the roots.
192*0eae32dcSDimitry Andric for (change_ty Change : Changes)
193*0eae32dcSDimitry Andric if (succ_begin(Change) == succ_end(Change))
194*0eae32dcSDimitry Andric Roots.push_back(Change);
1950b57cec5SDimitry Andric
1960b57cec5SDimitry Andric // Pre-compute the closure of the successor relation.
1970b57cec5SDimitry Andric std::vector<change_ty> Worklist(Roots.begin(), Roots.end());
1980b57cec5SDimitry Andric while (!Worklist.empty()) {
1990b57cec5SDimitry Andric change_ty Change = Worklist.back();
2000b57cec5SDimitry Andric Worklist.pop_back();
2010b57cec5SDimitry Andric
2020b57cec5SDimitry Andric std::set<change_ty> &ChangeSuccs = SuccClosure[Change];
2030b57cec5SDimitry Andric for (pred_iterator_ty it = pred_begin(Change),
2040b57cec5SDimitry Andric ie = pred_end(Change); it != ie; ++it) {
2050b57cec5SDimitry Andric SuccClosure[*it].insert(Change);
2060b57cec5SDimitry Andric SuccClosure[*it].insert(ChangeSuccs.begin(), ChangeSuccs.end());
2070b57cec5SDimitry Andric Worklist.push_back(*it);
2080b57cec5SDimitry Andric }
2090b57cec5SDimitry Andric }
2100b57cec5SDimitry Andric
2110b57cec5SDimitry Andric // Invert to form the predecessor closure map.
212*0eae32dcSDimitry Andric for (change_ty Change : Changes)
213*0eae32dcSDimitry Andric PredClosure.insert(std::make_pair(Change, std::set<change_ty>()));
214*0eae32dcSDimitry Andric for (change_ty Change : Changes)
215*0eae32dcSDimitry Andric for (succ_closure_iterator_ty it2 = succ_closure_begin(Change),
216*0eae32dcSDimitry Andric ie2 = succ_closure_end(Change);
217*0eae32dcSDimitry Andric it2 != ie2; ++it2)
218*0eae32dcSDimitry Andric PredClosure[*it2].insert(Change);
2190b57cec5SDimitry Andric
2200b57cec5SDimitry Andric // Dump useful debug info.
2210b57cec5SDimitry Andric LLVM_DEBUG({
2220b57cec5SDimitry Andric llvm::errs() << "-- DAGDeltaAlgorithmImpl --\n";
2230b57cec5SDimitry Andric llvm::errs() << "Changes: [";
2240b57cec5SDimitry Andric for (changeset_ty::const_iterator it = Changes.begin(), ie = Changes.end();
2250b57cec5SDimitry Andric it != ie; ++it) {
2260b57cec5SDimitry Andric if (it != Changes.begin())
2270b57cec5SDimitry Andric llvm::errs() << ", ";
2280b57cec5SDimitry Andric llvm::errs() << *it;
2290b57cec5SDimitry Andric
2300b57cec5SDimitry Andric if (succ_begin(*it) != succ_end(*it)) {
2310b57cec5SDimitry Andric llvm::errs() << "(";
2320b57cec5SDimitry Andric for (succ_iterator_ty it2 = succ_begin(*it), ie2 = succ_end(*it);
2330b57cec5SDimitry Andric it2 != ie2; ++it2) {
2340b57cec5SDimitry Andric if (it2 != succ_begin(*it))
2350b57cec5SDimitry Andric llvm::errs() << ", ";
2360b57cec5SDimitry Andric llvm::errs() << "->" << *it2;
2370b57cec5SDimitry Andric }
2380b57cec5SDimitry Andric llvm::errs() << ")";
2390b57cec5SDimitry Andric }
2400b57cec5SDimitry Andric }
2410b57cec5SDimitry Andric llvm::errs() << "]\n";
2420b57cec5SDimitry Andric
2430b57cec5SDimitry Andric llvm::errs() << "Roots: [";
2440b57cec5SDimitry Andric for (std::vector<change_ty>::const_iterator it = Roots.begin(),
2450b57cec5SDimitry Andric ie = Roots.end();
2460b57cec5SDimitry Andric it != ie; ++it) {
2470b57cec5SDimitry Andric if (it != Roots.begin())
2480b57cec5SDimitry Andric llvm::errs() << ", ";
2490b57cec5SDimitry Andric llvm::errs() << *it;
2500b57cec5SDimitry Andric }
2510b57cec5SDimitry Andric llvm::errs() << "]\n";
2520b57cec5SDimitry Andric
2530b57cec5SDimitry Andric llvm::errs() << "Predecessor Closure:\n";
254*0eae32dcSDimitry Andric for (change_ty Change : Changes) {
255*0eae32dcSDimitry Andric llvm::errs() << format(" %-4d: [", Change);
256*0eae32dcSDimitry Andric for (pred_closure_iterator_ty it2 = pred_closure_begin(Change),
257*0eae32dcSDimitry Andric ie2 = pred_closure_end(Change);
2580b57cec5SDimitry Andric it2 != ie2; ++it2) {
259*0eae32dcSDimitry Andric if (it2 != pred_closure_begin(Change))
2600b57cec5SDimitry Andric llvm::errs() << ", ";
2610b57cec5SDimitry Andric llvm::errs() << *it2;
2620b57cec5SDimitry Andric }
2630b57cec5SDimitry Andric llvm::errs() << "]\n";
2640b57cec5SDimitry Andric }
2650b57cec5SDimitry Andric
2660b57cec5SDimitry Andric llvm::errs() << "Successor Closure:\n";
267*0eae32dcSDimitry Andric for (change_ty Change : Changes) {
268*0eae32dcSDimitry Andric llvm::errs() << format(" %-4d: [", Change);
269*0eae32dcSDimitry Andric for (succ_closure_iterator_ty it2 = succ_closure_begin(Change),
270*0eae32dcSDimitry Andric ie2 = succ_closure_end(Change);
2710b57cec5SDimitry Andric it2 != ie2; ++it2) {
272*0eae32dcSDimitry Andric if (it2 != succ_closure_begin(Change))
2730b57cec5SDimitry Andric llvm::errs() << ", ";
2740b57cec5SDimitry Andric llvm::errs() << *it2;
2750b57cec5SDimitry Andric }
2760b57cec5SDimitry Andric llvm::errs() << "]\n";
2770b57cec5SDimitry Andric }
2780b57cec5SDimitry Andric
2790b57cec5SDimitry Andric llvm::errs() << "\n\n";
2800b57cec5SDimitry Andric });
2810b57cec5SDimitry Andric }
2820b57cec5SDimitry Andric
GetTestResult(const changeset_ty & Changes,const changeset_ty & Required)2830b57cec5SDimitry Andric bool DAGDeltaAlgorithmImpl::GetTestResult(const changeset_ty &Changes,
2840b57cec5SDimitry Andric const changeset_ty &Required) {
2850b57cec5SDimitry Andric changeset_ty Extended(Required);
2860b57cec5SDimitry Andric Extended.insert(Changes.begin(), Changes.end());
287*0eae32dcSDimitry Andric for (change_ty Change : Changes)
288*0eae32dcSDimitry Andric Extended.insert(pred_closure_begin(Change), pred_closure_end(Change));
2890b57cec5SDimitry Andric
2900b57cec5SDimitry Andric if (FailedTestsCache.count(Extended))
2910b57cec5SDimitry Andric return false;
2920b57cec5SDimitry Andric
2930b57cec5SDimitry Andric bool Result = ExecuteOneTest(Extended);
2940b57cec5SDimitry Andric if (!Result)
2950b57cec5SDimitry Andric FailedTestsCache.insert(Extended);
2960b57cec5SDimitry Andric
2970b57cec5SDimitry Andric return Result;
2980b57cec5SDimitry Andric }
2990b57cec5SDimitry Andric
3000b57cec5SDimitry Andric DAGDeltaAlgorithm::changeset_ty
Run()3010b57cec5SDimitry Andric DAGDeltaAlgorithmImpl::Run() {
3020b57cec5SDimitry Andric // The current set of changes we are minimizing, starting at the roots.
3030b57cec5SDimitry Andric changeset_ty CurrentSet(Roots.begin(), Roots.end());
3040b57cec5SDimitry Andric
3050b57cec5SDimitry Andric // The set of required changes.
3060b57cec5SDimitry Andric changeset_ty Required;
3070b57cec5SDimitry Andric
3080b57cec5SDimitry Andric // Iterate until the active set of changes is empty. Convergence is guaranteed
3090b57cec5SDimitry Andric // assuming input was a DAG.
3100b57cec5SDimitry Andric //
3110b57cec5SDimitry Andric // Invariant: CurrentSet intersect Required == {}
3120b57cec5SDimitry Andric // Invariant: Required == (Required union succ*(Required))
3130b57cec5SDimitry Andric while (!CurrentSet.empty()) {
3140b57cec5SDimitry Andric LLVM_DEBUG({
3150b57cec5SDimitry Andric llvm::errs() << "DAG_DD - " << CurrentSet.size() << " active changes, "
3160b57cec5SDimitry Andric << Required.size() << " required changes\n";
3170b57cec5SDimitry Andric });
3180b57cec5SDimitry Andric
3190b57cec5SDimitry Andric // Minimize the current set of changes.
3200b57cec5SDimitry Andric DeltaActiveSetHelper Helper(*this, Required);
3210b57cec5SDimitry Andric changeset_ty CurrentMinSet = Helper.Run(CurrentSet);
3220b57cec5SDimitry Andric
3230b57cec5SDimitry Andric // Update the set of required changes. Since
3240b57cec5SDimitry Andric // CurrentMinSet subset CurrentSet
3250b57cec5SDimitry Andric // and after the last iteration,
3260b57cec5SDimitry Andric // succ(CurrentSet) subset Required
3270b57cec5SDimitry Andric // then
3280b57cec5SDimitry Andric // succ(CurrentMinSet) subset Required
3290b57cec5SDimitry Andric // and our invariant on Required is maintained.
3300b57cec5SDimitry Andric Required.insert(CurrentMinSet.begin(), CurrentMinSet.end());
3310b57cec5SDimitry Andric
3320b57cec5SDimitry Andric // Replace the current set with the predecssors of the minimized set of
3330b57cec5SDimitry Andric // active changes.
3340b57cec5SDimitry Andric CurrentSet.clear();
335*0eae32dcSDimitry Andric for (change_ty CT : CurrentMinSet)
336*0eae32dcSDimitry Andric CurrentSet.insert(pred_begin(CT), pred_end(CT));
3370b57cec5SDimitry Andric
3380b57cec5SDimitry Andric // FIXME: We could enforce CurrentSet intersect Required == {} here if we
3390b57cec5SDimitry Andric // wanted to protect against cyclic graphs.
3400b57cec5SDimitry Andric }
3410b57cec5SDimitry Andric
3420b57cec5SDimitry Andric return Required;
3430b57cec5SDimitry Andric }
3440b57cec5SDimitry Andric
anchor()3450b57cec5SDimitry Andric void DAGDeltaAlgorithm::anchor() {
3460b57cec5SDimitry Andric }
3470b57cec5SDimitry Andric
3480b57cec5SDimitry Andric DAGDeltaAlgorithm::changeset_ty
Run(const changeset_ty & Changes,const std::vector<edge_ty> & Dependencies)3490b57cec5SDimitry Andric DAGDeltaAlgorithm::Run(const changeset_ty &Changes,
3500b57cec5SDimitry Andric const std::vector<edge_ty> &Dependencies) {
3510b57cec5SDimitry Andric return DAGDeltaAlgorithmImpl(*this, Changes, Dependencies).Run();
3520b57cec5SDimitry Andric }
353