summaryrefslogtreecommitdiff
path: root/src/passes/CodePushing.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-08-31 16:49:34 -0700
committerGitHub <noreply@github.com>2021-08-31 16:49:34 -0700
commit82cdabf20e496508cd241ef31a5f630c2de844ad (patch)
treed125e86b1bd50e85c20b540be1074ed655591b8f /src/passes/CodePushing.cpp
parent7d966528f603e65dacbf25f585a5accc46470bbd (diff)
downloadbinaryen-82cdabf20e496508cd241ef31a5f630c2de844ad.tar.gz
binaryen-82cdabf20e496508cd241ef31a5f630c2de844ad.tar.bz2
binaryen-82cdabf20e496508cd241ef31a5f630c2de844ad.zip
Use the new module version of EffectAnalyzer (#4116)
This finishes the refactoring started in #4115 by doing the same change to pass a Module into EffectAnalyzer instead of features. To do so this refactors the fallthrough API and a few other small things. After those changes, this PR removes the old feature constructor of EffectAnalyzer entirely. This requires a small breaking change in the C API, changing BinaryenExpressionGetSideEffects's feature param to a module. That makes this change not NFC, but otherwise it is.
Diffstat (limited to 'src/passes/CodePushing.cpp')
-rw-r--r--src/passes/CodePushing.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/passes/CodePushing.cpp b/src/passes/CodePushing.cpp
index c43028399..3ac11eebd 100644
--- a/src/passes/CodePushing.cpp
+++ b/src/passes/CodePushing.cpp
@@ -82,16 +82,16 @@ class Pusher {
LocalAnalyzer& analyzer;
std::vector<Index>& numGetsSoFar;
PassOptions& passOptions;
- FeatureSet features;
+ Module& module;
public:
Pusher(Block* block,
LocalAnalyzer& analyzer,
std::vector<Index>& numGetsSoFar,
PassOptions& passOptions,
- FeatureSet features)
+ Module& module)
: list(block->list), analyzer(analyzer), numGetsSoFar(numGetsSoFar),
- passOptions(passOptions), features(features) {
+ passOptions(passOptions), module(module) {
// Find an optimization segment: from the first pushable thing, to the first
// point past which we want to push. We then push in that range before
// continuing forward.
@@ -128,7 +128,7 @@ private:
// but also have no side effects, as it may not execute if pushed.
if (analyzer.isSFA(index) &&
numGetsSoFar[index] == analyzer.getNumGets(index) &&
- !EffectAnalyzer(passOptions, features, set->value).hasSideEffects()) {
+ !EffectAnalyzer(passOptions, module, set->value).hasSideEffects()) {
return set;
}
return nullptr;
@@ -159,7 +159,7 @@ private:
assert(firstPushable != Index(-1) && pushPoint != Index(-1) &&
firstPushable < pushPoint);
// everything that matters if you want to be pushed past the pushPoint
- EffectAnalyzer cumulativeEffects(passOptions, features);
+ EffectAnalyzer cumulativeEffects(passOptions, module);
cumulativeEffects.walk(list[pushPoint]);
// it is ok to ignore the branching here, that is the crucial point of this
// opt
@@ -177,7 +177,7 @@ private:
pushableEffects
.emplace(std::piecewise_construct,
std::forward_as_tuple(pushable),
- std::forward_as_tuple(passOptions, features, pushable))
+ std::forward_as_tuple(passOptions, module, pushable))
.first;
}
auto& effects = iter->second;
@@ -268,8 +268,7 @@ struct CodePushing : public WalkerPass<PostWalker<CodePushing>> {
// don't hit a non-control-flow ordering invalidation issue, since if this
// isn't a loop, it's fine (we're not used outside), and if it is, we hit
// the assign before any use (as we can't push it past a use).
- Pusher pusher(
- curr, analyzer, numGetsSoFar, getPassOptions(), getModule()->features);
+ Pusher pusher(curr, analyzer, numGetsSoFar, getPassOptions(), *getModule());
}
};