diff options
author | Thomas Lively <tlively@google.com> | 2022-09-30 18:17:45 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-30 23:17:45 +0000 |
commit | 2055ea3fd0391c1abb92cdec54f32274dc7fd971 (patch) | |
tree | 2d9ccaae076b065373b1507d75bc3886232363ec /src/passes/GlobalStructInference.cpp | |
parent | 62d056f889d4b94562a104e2fcad318857550d5b (diff) | |
download | binaryen-2055ea3fd0391c1abb92cdec54f32274dc7fd971.tar.gz binaryen-2055ea3fd0391c1abb92cdec54f32274dc7fd971.tar.bz2 binaryen-2055ea3fd0391c1abb92cdec54f32274dc7fd971.zip |
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.
Diffstat (limited to 'src/passes/GlobalStructInference.cpp')
-rw-r--r-- | src/passes/GlobalStructInference.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/passes/GlobalStructInference.cpp b/src/passes/GlobalStructInference.cpp index 1cba976a6..d0810a7fa 100644 --- a/src/passes/GlobalStructInference.cpp +++ b/src/passes/GlobalStructInference.cpp @@ -64,7 +64,7 @@ struct GlobalStructInference : public Pass { // them. If a global is not present here, it cannot be optimized. std::unordered_map<HeapType, std::vector<Name>> typeGlobals; - void run(PassRunner* runner, Module* module) override { + void run(Module* module) override { if (!module->features.hasGC()) { return; } @@ -185,7 +185,9 @@ struct GlobalStructInference : public Pass { : public WalkerPass<PostWalker<FunctionOptimizer>> { bool isFunctionParallel() override { return true; } - Pass* create() override { return new FunctionOptimizer(parent); } + std::unique_ptr<Pass> create() override { + return std::make_unique<FunctionOptimizer>(parent); + } FunctionOptimizer(GlobalStructInference& parent) : parent(parent) {} @@ -312,7 +314,7 @@ struct GlobalStructInference : public Pass { GlobalStructInference& parent; }; - FunctionOptimizer(*this).run(runner, module); + FunctionOptimizer(*this).run(getPassRunner(), module); } }; |