summaryrefslogtreecommitdiff
path: root/src/passes/SimplifyLocals.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-08-31 10:58:03 -0700
committerGitHub <noreply@github.com>2021-08-31 10:58:03 -0700
commit7d966528f603e65dacbf25f585a5accc46470bbd (patch)
treea07634a95dee38a611bc7fc29bc0828a7e8d1dfe /src/passes/SimplifyLocals.cpp
parent41fff9e2284e9be6e8a99da05beda54f398b0305 (diff)
downloadbinaryen-7d966528f603e65dacbf25f585a5accc46470bbd.tar.gz
binaryen-7d966528f603e65dacbf25f585a5accc46470bbd.tar.bz2
binaryen-7d966528f603e65dacbf25f585a5accc46470bbd.zip
Add a Module parameter to EffectAnalyzer. NFC (#4115)
Knowing the module will allow us to do more analysis in the effect analyzer. For now, this just refactors the code to allow providing a module instead of features, and to infer the features from the module. This actually shortens the code in most places which is nice (just pass module instead of module->features). This modifies basically all callers to use the new module form, except for the fallthrough logic. That would require some more refactoring, so to keep this PR reasonably small that is not yet done.
Diffstat (limited to 'src/passes/SimplifyLocals.cpp')
-rw-r--r--src/passes/SimplifyLocals.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp
index 77b8f1a93..ee0459d7d 100644
--- a/src/passes/SimplifyLocals.cpp
+++ b/src/passes/SimplifyLocals.cpp
@@ -79,10 +79,8 @@ struct SimplifyLocals
Expression** item;
EffectAnalyzer effects;
- SinkableInfo(Expression** item,
- PassOptions& passOptions,
- FeatureSet features)
- : item(item), effects(passOptions, features, *item) {}
+ SinkableInfo(Expression** item, PassOptions& passOptions, Module& module)
+ : item(item), effects(passOptions, module, *item) {}
};
// a list of sinkables in a linear execution trace
@@ -315,7 +313,7 @@ struct SimplifyLocals
}
}
- EffectAnalyzer effects(self->getPassOptions(), self->getModule()->features);
+ EffectAnalyzer effects(self->getPassOptions(), *self->getModule());
if (effects.checkPre(curr)) {
self->checkInvalidations(effects);
}
@@ -401,8 +399,7 @@ struct SimplifyLocals
}
}
- FeatureSet features = self->getModule()->features;
- EffectAnalyzer effects(self->getPassOptions(), features);
+ EffectAnalyzer effects(self->getPassOptions(), *self->getModule());
if (effects.checkPost(original)) {
self->checkInvalidations(effects);
}
@@ -411,7 +408,8 @@ struct SimplifyLocals
Index index = set->index;
assert(self->sinkables.count(index) == 0);
self->sinkables.emplace(std::make_pair(
- index, SinkableInfo(currp, self->getPassOptions(), features)));
+ index,
+ SinkableInfo(currp, self->getPassOptions(), *self->getModule())));
}
if (!allowNesting) {
@@ -428,7 +426,7 @@ struct SimplifyLocals
// 'catch', because 'pop' should follow right after 'catch'.
FeatureSet features = this->getModule()->features;
if (features.hasExceptionHandling() &&
- EffectAnalyzer(this->getPassOptions(), features, set->value)
+ EffectAnalyzer(this->getPassOptions(), *this->getModule(), set->value)
.danglingPop) {
return false;
}
@@ -530,7 +528,6 @@ struct SimplifyLocals
// )
// )
// so we must check for that.
- FeatureSet features = this->getModule()->features;
for (size_t j = 0; j < breaks.size(); j++) {
// move break local.set's value to the break
auto* breakLocalSetPointer = breaks[j].sinkables.at(sharedIndex).item;
@@ -548,8 +545,9 @@ struct SimplifyLocals
Nop nop;
*breakLocalSetPointer = &nop;
EffectAnalyzer condition(
- this->getPassOptions(), features, br->condition);
- EffectAnalyzer value(this->getPassOptions(), features, set);
+ this->getPassOptions(), *this->getModule(), br->condition);
+ EffectAnalyzer value(
+ this->getPassOptions(), *this->getModule(), set);
*breakLocalSetPointer = set;
if (condition.invalidates(value)) {
// indeed, we can't do this, stop