diff options
author | Alon Zakai <azakai@google.com> | 2023-08-07 09:36:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-07 09:36:12 -0700 |
commit | 88762a2a6204cceb153b13238e17f9076259f4bd (patch) | |
tree | 5b65f4ebeff3cdae2271ad2d3f5611805bb3d9b0 /src/passes/SimplifyLocals.cpp | |
parent | bcdfa72afe41746ac13d27e6d02866c7d11e7fb5 (diff) | |
download | binaryen-88762a2a6204cceb153b13238e17f9076259f4bd.tar.gz binaryen-88762a2a6204cceb153b13238e17f9076259f4bd.tar.bz2 binaryen-88762a2a6204cceb153b13238e17f9076259f4bd.zip |
Fix LinearExecutionWalker on calls (#5857)
Calls were simply not handled there, so we could think we were still in the same
basic block when we were not, affecting various passes (but somehow this went
unnoticed until the TNHOracle #5850 ran on some particular Java code).
One existing test was affected, and two new tests are added: one for TNHOracle
where I detected this, and one in OptimizeCasts which is perhaps a simpler way
to see the problem.
All the cases but the TNH one, however, do not need this fix for correctness
since they actually don't care if a call would throw. As a TODO, we should find a
way to undo this minor regression. The regression only affects builds with EH
enabled, though, so most users should be unaffected even in the interm.
Diffstat (limited to 'src/passes/SimplifyLocals.cpp')
-rw-r--r-- | src/passes/SimplifyLocals.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp index a042ba573..ff2141fb4 100644 --- a/src/passes/SimplifyLocals.cpp +++ b/src/passes/SimplifyLocals.cpp @@ -997,9 +997,9 @@ struct SimplifyLocals // will inhibit us creating an if return value. struct EquivalentOptimizer : public LinearExecutionWalker<EquivalentOptimizer> { + std::vector<Index>* numLocalGets; bool removeEquivalentSets; - Module* module; PassOptions passOptions; bool anotherCycle = false; @@ -1016,6 +1016,8 @@ struct SimplifyLocals } void visitLocalSet(LocalSet* curr) { + auto* module = this->getModule(); + // Remove trivial copies, even through a tee auto* value = Properties::getFallthrough(curr->value, passOptions, *module); @@ -1123,11 +1125,10 @@ struct SimplifyLocals }; EquivalentOptimizer eqOpter; - eqOpter.module = this->getModule(); eqOpter.passOptions = this->getPassOptions(); eqOpter.numLocalGets = &getCounter.num; eqOpter.removeEquivalentSets = allowStructure; - eqOpter.walkFunction(func); + eqOpter.walkFunctionInModule(func, this->getModule()); if (eqOpter.refinalize) { ReFinalize().walkFunctionInModule(func, this->getModule()); } |