diff options
author | Alon Zakai <azakai@google.com> | 2021-03-29 13:17:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-29 13:17:06 -0700 |
commit | 41594d7a5bad76f567559e9496ab3d98ba170361 (patch) | |
tree | 5206eb59ce259cb242bbebf24241c66fae07f4ac /src | |
parent | 1a6efdb4233a077bc6e5e8a340baf5672bb5bced (diff) | |
download | binaryen-41594d7a5bad76f567559e9496ab3d98ba170361.tar.gz binaryen-41594d7a5bad76f567559e9496ab3d98ba170361.tar.bz2 binaryen-41594d7a5bad76f567559e9496ab3d98ba170361.zip |
handleNonNullableLocals(): Do not modify params (#3740)
Parameters can be non-nullable, and must stay so if they began as such.
By mistake we modified them with the vars.
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/type-updating.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ir/type-updating.cpp b/src/ir/type-updating.cpp index 54a83aa49..312540b53 100644 --- a/src/ir/type-updating.cpp +++ b/src/ir/type-updating.cpp @@ -37,6 +37,10 @@ void handleNonNullableLocals(Function* func, Module& wasm) { Builder builder(wasm); for (auto** getp : FindAllPointers<LocalGet>(func->body).list) { auto* get = (*getp)->cast<LocalGet>(); + if (!func->isVar(get->index)) { + // We do not need to process params, which can legally be non-nullable. + continue; + } auto type = func->getLocalType(get->index); if (type.isRef() && !type.isNullable()) { // The get should now return a nullable value, and a ref.as_non_null |