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/ir/module-utils.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/ir/module-utils.h') diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h index 319f1a7a4..cdafa9c8c 100644 --- a/src/ir/module-utils.h +++ b/src/ir/module-utils.h @@ -201,7 +201,9 @@ template inline void renameFunctions(Module& wasm, T& map) { Updater(T& map) : map(map) {} - Updater* create() override { return new Updater(map); } + std::unique_ptr create() override { + return std::make_unique(map); + } void visitCall(Call* curr) { maybeUpdate(curr->target); } @@ -392,7 +394,9 @@ struct ParallelFunctionAnalysis { Mapper(Module& module, Map& map, Func work) : module(module), map(map), work(work) {} - Mapper* create() override { return new Mapper(module, map, work); } + std::unique_ptr create() override { + return std::make_unique(module, map, work); + } void doWalkFunction(Function* curr) { assert(map.count(curr)); -- cgit v1.2.3