summaryrefslogtreecommitdiff
path: root/src/passes/ReorderGlobals.cpp
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-09-03 09:21:07 -0700
committerGitHub <noreply@github.com>2024-09-03 09:21:07 -0700
commitb7cdb8c2110dff5a9b096d766dac04cd8ec04cc9 (patch)
tree401a90a9b28a625638c2bc9c6f687bb3662862bc /src/passes/ReorderGlobals.cpp
parent871ff0d4f910b565c15f82e8f3c9aa769b01d286 (diff)
downloadbinaryen-b7cdb8c2110dff5a9b096d766dac04cd8ec04cc9.tar.gz
binaryen-b7cdb8c2110dff5a9b096d766dac04cd8ec04cc9.tar.bz2
binaryen-b7cdb8c2110dff5a9b096d766dac04cd8ec04cc9.zip
[NFC] Change topological sort utilities to functions (#6889)
Previously they were structs and their results were accessed with `operator*()`, but that was unnecessarily complicated and could lead to problems with temporary lifetimes being too short. Simplify the utilities by making them functions. This also allows the wrapper templates to infer the proper element types automatically.
Diffstat (limited to 'src/passes/ReorderGlobals.cpp')
-rw-r--r--src/passes/ReorderGlobals.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/passes/ReorderGlobals.cpp b/src/passes/ReorderGlobals.cpp
index d17bb86cc..dab4625fe 100644
--- a/src/passes/ReorderGlobals.cpp
+++ b/src/passes/ReorderGlobals.cpp
@@ -199,8 +199,7 @@ struct ReorderGlobals : public Pass {
}
}
- auto sort = *TopologicalSort(dependenceGraph);
- for (auto global : sort) {
+ for (auto global : TopologicalSort::sort(dependenceGraph)) {
// We can compute this global's count as in the sorted order all the
// values it cares about are resolved. Start with the self-count, then
// add the deps.
@@ -294,7 +293,7 @@ struct ReorderGlobals : public Pass {
graph.emplace_back(i, std::move(children));
}
- return *MinTopologicalSortOf<Index>(graph.begin(), graph.end());
+ return TopologicalSort::minSortOf(graph.begin(), graph.end());
}
// Given an indexing of the globals and the counts of how many times each is