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/ExtractFunction.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/passes/ExtractFunction.cpp') diff --git a/src/passes/ExtractFunction.cpp b/src/passes/ExtractFunction.cpp index f75c04cbe..e3f2a5538 100644 --- a/src/passes/ExtractFunction.cpp +++ b/src/passes/ExtractFunction.cpp @@ -54,25 +54,24 @@ static void extract(PassRunner* runner, Module* module, Name name) { // Remove unneeded things. PassRunner postRunner(runner); postRunner.add("remove-unused-module-elements"); - postRunner.setIsNested(true); postRunner.run(); } struct ExtractFunction : public Pass { - void run(PassRunner* runner, Module* module) override { - Name name = runner->options.getArgument( + void run(Module* module) override { + Name name = getPassOptions().getArgument( "extract-function", "ExtractFunction usage: wasm-opt --extract-function=FUNCTION_NAME"); - extract(runner, module, name); + extract(getPassRunner(), module, name); } }; struct ExtractFunctionIndex : public Pass { - void run(PassRunner* runner, Module* module) override { + void run(Module* module) override { std::string index = - runner->options.getArgument("extract-function-index", - "ExtractFunctionIndex usage: wasm-opt " - "--extract-function-index=FUNCTION_INDEX"); + getPassOptions().getArgument("extract-function-index", + "ExtractFunctionIndex usage: wasm-opt " + "--extract-function-index=FUNCTION_INDEX"); for (char c : index) { if (!std::isdigit(c)) { Fatal() << "Expected numeric function index"; @@ -85,7 +84,7 @@ struct ExtractFunctionIndex : public Pass { } // Assumes imports are at the beginning Name name = module->functions[i]->name; - extract(runner, module, name); + extract(getPassRunner(), module, name); } }; -- cgit v1.2.3