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/GlobalEffects.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/passes/GlobalEffects.cpp') diff --git a/src/passes/GlobalEffects.cpp b/src/passes/GlobalEffects.cpp index 2f816a0bd..6ed2d413a 100644 --- a/src/passes/GlobalEffects.cpp +++ b/src/passes/GlobalEffects.cpp @@ -26,11 +26,11 @@ namespace wasm { struct GenerateGlobalEffects : public Pass { - void run(PassRunner* runner, Module* module) override { + void run(Module* module) override { // TODO: Full transitive closure of effects. For now, we just look at each // function by itself. - auto& funcEffectsMap = runner->options.funcEffectsMap; + auto& funcEffectsMap = getPassOptions().funcEffectsMap; // First, clear any previous effects. funcEffectsMap.reset(); @@ -50,7 +50,7 @@ struct GenerateGlobalEffects : public Pass { // Gather the effects. auto effects = - std::make_unique(runner->options, *module, func); + std::make_unique(getPassOptions(), *module, func); // If the body has a call, give up - that means we can't infer a more // specific set of effects than the pessimistic case of just assuming @@ -80,9 +80,7 @@ struct GenerateGlobalEffects : public Pass { }; struct DiscardGlobalEffects : public Pass { - void run(PassRunner* runner, Module* module) override { - runner->options.funcEffectsMap.reset(); - } + void run(Module* module) override { getPassOptions().funcEffectsMap.reset(); } }; Pass* createGenerateGlobalEffectsPass() { return new GenerateGlobalEffects(); } -- cgit v1.2.3