summaryrefslogtreecommitdiff
path: root/src/ir/local-utils.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-11-22 11:03:44 -0800
committerGitHub <noreply@github.com>2022-11-22 19:03:44 +0000
commit776c15a1ae4a6c8b97784bd60c6696fdb4e626ef (patch)
treebb22dc9389a9d2618f0312069d6d365cc93158dc /src/ir/local-utils.h
parent8e478839e825f4870d5205bca5e7f7cb33905da8 (diff)
downloadbinaryen-776c15a1ae4a6c8b97784bd60c6696fdb4e626ef.tar.gz
binaryen-776c15a1ae4a6c8b97784bd60c6696fdb4e626ef.tar.bz2
binaryen-776c15a1ae4a6c8b97784bd60c6696fdb4e626ef.zip
[Wasm GC] Refinalize in UnneededSetRemover when necessary (#5287)
Diffstat (limited to 'src/ir/local-utils.h')
-rw-r--r--src/ir/local-utils.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ir/local-utils.h b/src/ir/local-utils.h
index ef74a35eb..153ebd3f3 100644
--- a/src/ir/local-utils.h
+++ b/src/ir/local-utils.h
@@ -19,6 +19,7 @@
#include <ir/effects.h>
#include <ir/manipulation.h>
+#include <ir/utils.h>
namespace wasm {
@@ -61,9 +62,14 @@ struct UnneededSetRemover : public PostWalker<UnneededSetRemover> {
: passOptions(passOptions), localGetCounter(&localGetCounter),
module(module) {
walk(func->body);
+
+ if (refinalize) {
+ ReFinalize().walkFunctionInModule(func, &module);
+ }
}
bool removed = false;
+ bool refinalize = false;
void visitLocalSet(LocalSet* curr) {
// If no possible uses, remove.
@@ -94,6 +100,10 @@ struct UnneededSetRemover : public PostWalker<UnneededSetRemover> {
auto* value = set->value;
if (set->isTee()) {
replaceCurrent(value);
+ if (value->type != set->type) {
+ // The value is more refined, so we'll need to refinalize.
+ refinalize = true;
+ }
} else if (EffectAnalyzer(passOptions, module, set->value)
.hasSideEffects()) {
Drop* drop = ExpressionManipulator::convert<LocalSet, Drop>(set);