From 2055ea3fd0391c1abb92cdec54f32274dc7fd971 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Fri, 30 Sep 2022 18:17:45 -0500 Subject: Refactor interaction between Pass and PassRunner (#5093) Previously only WalkerPasses had access to the `getPassRunner` and `getPassOptions` methods. Move those methods to `Pass` so all passes can use them. As a result, the `PassRunner` passed to `Pass::run` and `Pass::runOnFunction` is no longer necessary, so remove it. Also update `Pass::create` to return a unique_ptr, which is more efficient than having it return a raw pointer only to have the `PassRunner` wrap that raw pointer in a `unique_ptr`. Delete the unused template `PassRunner::getLast()`, which looks like it was intended to enable retrieving previous analyses and has been in the code base since 2015 but is not implemented anywhere. --- src/passes/DuplicateFunctionElimination.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/passes/DuplicateFunctionElimination.cpp') diff --git a/src/passes/DuplicateFunctionElimination.cpp b/src/passes/DuplicateFunctionElimination.cpp index 2ebdca4ba..e797cd843 100644 --- a/src/passes/DuplicateFunctionElimination.cpp +++ b/src/passes/DuplicateFunctionElimination.cpp @@ -37,11 +37,11 @@ struct DuplicateFunctionElimination : public Pass { // This pass merges functions but does not alter their contents. bool requiresNonNullableLocalFixups() override { return false; } - void run(PassRunner* runner, Module* module) override { + void run(Module* module) override { // Multiple iterations may be necessary: A and B may be identical only after // we see the functions C1 and C2 that they call are in fact identical. // Rarely, such "chains" can be very long, so we limit how many we do. - auto& options = runner->options; + auto& options = getPassOptions(); Index limit; if (options.optimizeLevel >= 3 || options.shrinkLevel >= 1) { limit = module->functions.size(); // no limit @@ -56,7 +56,7 @@ struct DuplicateFunctionElimination : public Pass { limit--; // Hash all the functions auto hashes = FunctionHasher::createMap(module); - FunctionHasher(&hashes).run(runner, module); + FunctionHasher(&hashes).run(getPassRunner(), module); // Find hash-equal groups std::map> hashGroups; ModuleUtils::iterDefinedFunctions(*module, [&](Function* func) { @@ -96,7 +96,7 @@ struct DuplicateFunctionElimination : public Pass { // remove the duplicates module->removeFunctions( [&](Function* func) { return duplicates.count(func->name) > 0; }); - OptUtils::replaceFunctions(runner, *module, replacements); + OptUtils::replaceFunctions(getPassRunner(), *module, replacements); } else { break; } -- cgit v1.2.3