aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Support/DAGDeltaAlgorithm.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-12-25 22:36:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-06-04 11:59:11 +0000
commit8a84287b0edc66fc6dede3db770d10ff41da5464 (patch)
treebb9f1a9efd9c27bbf1594795f8e16a76a572c4e1 /contrib/llvm-project/llvm/lib/Support/DAGDeltaAlgorithm.cpp
parent574b7079b96703a748f89ef5adb7dc3e26b8f7fc (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Support/DAGDeltaAlgorithm.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Support/DAGDeltaAlgorithm.cpp68
1 files changed, 30 insertions, 38 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/DAGDeltaAlgorithm.cpp b/contrib/llvm-project/llvm/lib/Support/DAGDeltaAlgorithm.cpp
index e5e6301d41cc..a6daee00bd43 100644
--- a/contrib/llvm-project/llvm/lib/Support/DAGDeltaAlgorithm.cpp
+++ b/contrib/llvm-project/llvm/lib/Support/DAGDeltaAlgorithm.cpp
@@ -180,22 +180,19 @@ DAGDeltaAlgorithmImpl::DAGDeltaAlgorithmImpl(
DAGDeltaAlgorithm &DDA, const changeset_ty &Changes,
const std::vector<edge_ty> &Dependencies)
: DDA(DDA) {
- for (changeset_ty::const_iterator it = Changes.begin(),
- ie = Changes.end(); it != ie; ++it) {
- Predecessors.insert(std::make_pair(*it, std::vector<change_ty>()));
- Successors.insert(std::make_pair(*it, std::vector<change_ty>()));
+ for (change_ty Change : Changes) {
+ Predecessors.insert(std::make_pair(Change, std::vector<change_ty>()));
+ Successors.insert(std::make_pair(Change, std::vector<change_ty>()));
}
- for (std::vector<edge_ty>::const_iterator it = Dependencies.begin(),
- ie = Dependencies.end(); it != ie; ++it) {
- Predecessors[it->second].push_back(it->first);
- Successors[it->first].push_back(it->second);
+ for (const edge_ty &Dep : Dependencies) {
+ Predecessors[Dep.second].push_back(Dep.first);
+ Successors[Dep.first].push_back(Dep.second);
}
// Compute the roots.
- for (changeset_ty::const_iterator it = Changes.begin(),
- ie = Changes.end(); it != ie; ++it)
- if (succ_begin(*it) == succ_end(*it))
- Roots.push_back(*it);
+ for (change_ty Change : Changes)
+ if (succ_begin(Change) == succ_end(Change))
+ Roots.push_back(Change);
// Pre-compute the closure of the successor relation.
std::vector<change_ty> Worklist(Roots.begin(), Roots.end());
@@ -213,14 +210,13 @@ DAGDeltaAlgorithmImpl::DAGDeltaAlgorithmImpl(
}
// Invert to form the predecessor closure map.
- for (changeset_ty::const_iterator it = Changes.begin(),
- ie = Changes.end(); it != ie; ++it)
- PredClosure.insert(std::make_pair(*it, std::set<change_ty>()));
- for (changeset_ty::const_iterator it = Changes.begin(),
- ie = Changes.end(); it != ie; ++it)
- for (succ_closure_iterator_ty it2 = succ_closure_begin(*it),
- ie2 = succ_closure_end(*it); it2 != ie2; ++it2)
- PredClosure[*it2].insert(*it);
+ for (change_ty Change : Changes)
+ PredClosure.insert(std::make_pair(Change, std::set<change_ty>()));
+ for (change_ty Change : Changes)
+ for (succ_closure_iterator_ty it2 = succ_closure_begin(Change),
+ ie2 = succ_closure_end(Change);
+ it2 != ie2; ++it2)
+ PredClosure[*it2].insert(Change);
// Dump useful debug info.
LLVM_DEBUG({
@@ -256,13 +252,12 @@ DAGDeltaAlgorithmImpl::DAGDeltaAlgorithmImpl(
llvm::errs() << "]\n";
llvm::errs() << "Predecessor Closure:\n";
- for (changeset_ty::const_iterator it = Changes.begin(), ie = Changes.end();
- it != ie; ++it) {
- llvm::errs() << format(" %-4d: [", *it);
- for (pred_closure_iterator_ty it2 = pred_closure_begin(*it),
- ie2 = pred_closure_end(*it);
+ for (change_ty Change : Changes) {
+ llvm::errs() << format(" %-4d: [", Change);
+ for (pred_closure_iterator_ty it2 = pred_closure_begin(Change),
+ ie2 = pred_closure_end(Change);
it2 != ie2; ++it2) {
- if (it2 != pred_closure_begin(*it))
+ if (it2 != pred_closure_begin(Change))
llvm::errs() << ", ";
llvm::errs() << *it2;
}
@@ -270,13 +265,12 @@ DAGDeltaAlgorithmImpl::DAGDeltaAlgorithmImpl(
}
llvm::errs() << "Successor Closure:\n";
- for (changeset_ty::const_iterator it = Changes.begin(), ie = Changes.end();
- it != ie; ++it) {
- llvm::errs() << format(" %-4d: [", *it);
- for (succ_closure_iterator_ty it2 = succ_closure_begin(*it),
- ie2 = succ_closure_end(*it);
+ for (change_ty Change : Changes) {
+ llvm::errs() << format(" %-4d: [", Change);
+ for (succ_closure_iterator_ty it2 = succ_closure_begin(Change),
+ ie2 = succ_closure_end(Change);
it2 != ie2; ++it2) {
- if (it2 != succ_closure_begin(*it))
+ if (it2 != succ_closure_begin(Change))
llvm::errs() << ", ";
llvm::errs() << *it2;
}
@@ -291,9 +285,8 @@ bool DAGDeltaAlgorithmImpl::GetTestResult(const changeset_ty &Changes,
const changeset_ty &Required) {
changeset_ty Extended(Required);
Extended.insert(Changes.begin(), Changes.end());
- for (changeset_ty::const_iterator it = Changes.begin(),
- ie = Changes.end(); it != ie; ++it)
- Extended.insert(pred_closure_begin(*it), pred_closure_end(*it));
+ for (change_ty Change : Changes)
+ Extended.insert(pred_closure_begin(Change), pred_closure_end(Change));
if (FailedTestsCache.count(Extended))
return false;
@@ -340,9 +333,8 @@ DAGDeltaAlgorithmImpl::Run() {
// Replace the current set with the predecssors of the minimized set of
// active changes.
CurrentSet.clear();
- for (changeset_ty::const_iterator it = CurrentMinSet.begin(),
- ie = CurrentMinSet.end(); it != ie; ++it)
- CurrentSet.insert(pred_begin(*it), pred_end(*it));
+ for (change_ty CT : CurrentMinSet)
+ CurrentSet.insert(pred_begin(CT), pred_end(CT));
// FIXME: We could enforce CurrentSet intersect Required == {} here if we
// wanted to protect against cyclic graphs.