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/ReorderFunctions.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/ReorderFunctions.cpp')
-rw-r--r-- | src/passes/ReorderFunctions.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/passes/ReorderFunctions.cpp b/src/passes/ReorderFunctions.cpp index 6f87e74a6..b6c7a4984 100644 --- a/src/passes/ReorderFunctions.cpp +++ b/src/passes/ReorderFunctions.cpp @@ -44,7 +44,9 @@ struct CallCountScanner : public WalkerPass<PostWalker<CallCountScanner>> { CallCountScanner(NameCountMap* counts) : counts(counts) {} - CallCountScanner* create() override { return new CallCountScanner(counts); } + std::unique_ptr<Pass> create() override { + return std::make_unique<CallCountScanner>(counts); + } void visitCall(Call* curr) { // can't add a new element in parallel @@ -60,7 +62,7 @@ struct ReorderFunctions : public Pass { // Only reorders functions, does not change their contents. bool requiresNonNullableLocalFixups() override { return false; } - void run(PassRunner* runner, Module* module) override { + void run(Module* module) override { NameCountMap counts; // fill in info, as we operate on it in parallel (each function to its own // entry) @@ -68,7 +70,7 @@ struct ReorderFunctions : public Pass { counts[func->name]; } // find counts on function calls - CallCountScanner(&counts).run(runner, module); + CallCountScanner(&counts).run(getPassRunner(), module); // find counts on global usages if (module->start.is()) { counts[module->start]++; |