summaryrefslogtreecommitdiff
path: root/src/passes/Inlining.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-06-18 17:04:06 -0700
committerGitHub <noreply@github.com>2021-06-18 17:04:06 -0700
commitaae35755e1d047c1f6fba9abfd2d836feafa5f66 (patch)
treef29fb2ad1de40ef80c3a9468a825ad4a61a670e0 /src/passes/Inlining.cpp
parent28e88b9f993a2e45662fde0b10920aa22e7b1b7f (diff)
downloadbinaryen-aae35755e1d047c1f6fba9abfd2d836feafa5f66.tar.gz
binaryen-aae35755e1d047c1f6fba9abfd2d836feafa5f66.tar.bz2
binaryen-aae35755e1d047c1f6fba9abfd2d836feafa5f66.zip
[Wasm GC] Fix inlining + non-nullable locals (#3945)
We don't need to assign a zero value for such locals (and we can't, as no default value exists for them). Fixes #3944
Diffstat (limited to 'src/passes/Inlining.cpp')
-rw-r--r--src/passes/Inlining.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp
index 78f9966e7..8601b3409 100644
--- a/src/passes/Inlining.cpp
+++ b/src/passes/Inlining.cpp
@@ -292,9 +292,16 @@ doInlining(Module* module, Function* into, const InliningAction& action) {
// Zero out the vars (as we may be in a loop, and may depend on their
// zero-init value
for (Index i = 0; i < from->vars.size(); i++) {
+ auto type = from->vars[i];
+ if (type.isRef() && !type.isNullable()) {
+ // Non-nullable locals do not need to be zeroed out. They have no zero
+ // value, and by definition should not be used before being written to, so
+ // any value we set here would not be observed anyhow.
+ continue;
+ }
block->list.push_back(
builder.makeLocalSet(updater.localMapping[from->getVarIndexBase() + i],
- LiteralUtils::makeZero(from->vars[i], *module)));
+ LiteralUtils::makeZero(type, *module)));
}
// Generate and update the inlined contents
auto* contents = ExpressionManipulator::copy(from->body, *module);