Skip to content

Commit 1abcee9

Browse files
authored
Avoid use of C++20 <ranges> header in GlobalEffects.cpp (#8668)
Avoid use of C++20 <ranges> header in GlobalEffects.cpp, so that the code builds on Clang-14 as well.
1 parent 35ca7ce commit 1abcee9

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

src/passes/GlobalEffects.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
// PassOptions structure; see more details there.
2020
//
2121

22-
#include <ranges>
23-
2422
#include "ir/effects.h"
2523
#include "ir/module-utils.h"
2624
#include "pass.h"
@@ -234,26 +232,26 @@ void propagateEffects(const Module& module,
234232
// We only care about Functions that are roots, not types.
235233
// A type would be a root if a function exists with that type, but no-one
236234
// indirect calls the type.
237-
auto funcNodes = std::views::keys(callGraph) |
238-
std::views::filter([](auto node) {
239-
return std::holds_alternative<Function*>(node);
240-
}) |
241-
std::views::common;
242-
using funcNodesType = decltype(funcNodes);
235+
std::vector<CallGraphNode> funcNodes;
236+
for (const auto& [node, _] : callGraph) {
237+
if (std::holds_alternative<Function*>(node)) {
238+
funcNodes.push_back(node);
239+
}
240+
}
243241

244242
struct CallGraphSCCs
245-
: SCCs<std::ranges::iterator_t<funcNodesType>, CallGraphSCCs> {
243+
: SCCs<std::vector<CallGraphNode>::iterator, CallGraphSCCs> {
246244

247245
const std::map<Function*, FuncInfo>& funcInfos;
248246
const CallGraph& callGraph;
249247
const Module& module;
250248

251-
CallGraphSCCs(funcNodesType&& nodes,
249+
CallGraphSCCs(std::vector<CallGraphNode>& nodes,
252250
const std::map<Function*, FuncInfo>& funcInfos,
253251
const CallGraph& callGraph,
254252
const Module& module)
255-
: SCCs<std::ranges::iterator_t<funcNodesType>, CallGraphSCCs>(
256-
std::ranges::begin(nodes), std::ranges::end(nodes)),
253+
: SCCs<std::vector<CallGraphNode>::iterator, CallGraphSCCs>(nodes.begin(),
254+
nodes.end()),
257255
funcInfos(funcInfos), callGraph(callGraph), module(module) {}
258256

259257
void pushChildren(CallGraphNode node) {
@@ -262,7 +260,7 @@ void propagateEffects(const Module& module,
262260
}
263261
}
264262
};
265-
CallGraphSCCs sccs(std::move(funcNodes), funcInfos, callGraph, module);
263+
CallGraphSCCs sccs(funcNodes, funcInfos, callGraph, module);
266264

267265
std::vector<std::optional<EffectAnalyzer>> componentEffects;
268266
// Points to an index in componentEffects

0 commit comments

Comments
 (0)