summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-04-04 11:05:43 -0700
committerGitHub <noreply@github.com>2023-04-04 11:05:43 -0700
commit05e1183954e49f8b3a1669cc7973af590afe9fc3 (patch)
treeee48c306f0262a01cb6cc76bced147d9e656fbf0 /src
parent48e9c8150f06bc1a4d470a214bf5394c9aa9d524 (diff)
downloadbinaryen-05e1183954e49f8b3a1669cc7973af590afe9fc3.tar.gz
binaryen-05e1183954e49f8b3a1669cc7973af590afe9fc3.tar.bz2
binaryen-05e1183954e49f8b3a1669cc7973af590afe9fc3.zip
[Wasm GC] Fix CoalesceLocals i31 local.get removal (#5619)
When removing a local.get we must replace it with something of the identical type, and not make it non-nullable.
Diffstat (limited to 'src')
-rw-r--r--src/wasm-builder.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index 8b34d6933..73803e37d 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -1295,7 +1295,12 @@ public:
return ExpressionManipulator::refNull(curr, curr->type);
}
if (curr->type.isRef() && curr->type.getHeapType() == HeapType::i31) {
- return makeI31New(makeConst(0));
+ Expression* ret = makeI31New(makeConst(0));
+ if (curr->type.isNullable()) {
+ // To keep the type identical, wrap it in a block that adds nullability.
+ ret = makeBlock({ret}, curr->type);
+ }
+ return ret;
}
if (!curr->type.isBasic()) {
// We can't do any better, keep the original.