diff options
author | Alon Zakai <azakai@google.com> | 2019-07-19 16:01:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-19 16:01:15 -0700 |
commit | 88ef839433ac0cf58c2a29f369d0268a22b5ae0e (patch) | |
tree | 13488bb2eda5657d7cb440cacacab4369b7fda1e /src/passes/SimplifyGlobals.cpp | |
parent | 7bc5f1891f77e53f5a4e6905e02e80c680c728c3 (diff) | |
download | binaryen-88ef839433ac0cf58c2a29f369d0268a22b5ae0e.tar.gz binaryen-88ef839433ac0cf58c2a29f369d0268a22b5ae0e.tar.bz2 binaryen-88ef839433ac0cf58c2a29f369d0268a22b5ae0e.zip |
Simpify PassRunner.add() and automatically parallelize parallel functions (#2242)
Main change here is in pass.h, everything else is changes to work with the new API.
The add("name") remains as before, while the weird variadic add(..) which constructed the pass now just gets a std::unique_ptr of a pass. This also makes the memory management internally fully automatic. And it makes it trivial to parallelize WalkerPass::run on parallel passes.
As a benefit, this allows removing a lot of code since in many cases there is no need to create a new pass runner, and running a pass can be just a single line.
Diffstat (limited to 'src/passes/SimplifyGlobals.cpp')
-rw-r--r-- | src/passes/SimplifyGlobals.cpp | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/passes/SimplifyGlobals.cpp b/src/passes/SimplifyGlobals.cpp index 992126cfe..a111f31b5 100644 --- a/src/passes/SimplifyGlobals.cpp +++ b/src/passes/SimplifyGlobals.cpp @@ -119,11 +119,7 @@ struct SimplifyGlobals : public Pass { map[ex->value].exported = true; } } - { - PassRunner subRunner(module, runner->options); - subRunner.add<GlobalUseScanner>(&map); - subRunner.run(); - } + GlobalUseScanner(&map).run(runner, module); // We now know which are immutable in practice. for (auto& global : module->globals) { auto& info = map[global->name]; @@ -157,9 +153,7 @@ struct SimplifyGlobals : public Pass { } } // Apply to the gets. - PassRunner subRunner(module, runner->options); - subRunner.add<GlobalUseModifier>(&copiedParentMap); - subRunner.run(); + GlobalUseModifier(&copiedParentMap).run(runner, module); } // If any immutable globals have constant values, we can just apply them // (the global itself will be removed by another pass, as it/ won't have @@ -172,9 +166,7 @@ struct SimplifyGlobals : public Pass { } } if (!constantGlobals.empty()) { - PassRunner subRunner(module, runner->options); - subRunner.add<ConstantGlobalApplier>(&constantGlobals); - subRunner.run(); + ConstantGlobalApplier(&constantGlobals).run(runner, module); } // TODO a mutable global's initial value can be applied to another global // after it, as the mutable one can't mutate during instance startup |