summaryrefslogtreecommitdiff
path: root/src/passes/Inlining.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/Inlining.cpp')
-rw-r--r--src/passes/Inlining.cpp23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp
index 10b41abc0..96c4531c8 100644
--- a/src/passes/Inlining.cpp
+++ b/src/passes/Inlining.cpp
@@ -385,23 +385,12 @@ struct Inlining : public Pass {
OptUtils::optimizeAfterInlining(inlinedInto, module, runner);
}
// remove functions that we no longer need after inlining
- auto& funcs = module->functions;
- funcs.erase(std::remove_if(funcs.begin(),
- funcs.end(),
- [&](const std::unique_ptr<Function>& curr) {
- auto name = curr->name;
- auto& info = infos[name];
- bool canRemove =
- inlinedUses.count(name) &&
- inlinedUses[name] == info.calls &&
- !info.usedGlobally;
-#ifdef INLINING_DEBUG
- if (canRemove)
- std::cout << "removing " << name << '\n';
-#endif
- return canRemove;
- }),
- funcs.end());
+ module->removeFunctions([&](Function* func) {
+ auto name = func->name;
+ auto& info = infos[name];
+ return inlinedUses.count(name) && inlinedUses[name] == info.calls &&
+ !info.usedGlobally;
+ });
// return whether we did any work
return inlinedUses.size() > 0;
}