From be580c66645cdea13c8e8b3b77f12ef3a52e5f2e Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 28 Jul 2021 09:11:43 -0700 Subject: [Wasm GC] DeadArgumentElimination: Update tees after refining param types (#4031) --- src/passes/DeadArgumentElimination.cpp | 15 +++++++++++++-- src/passes/LocalSubtyping.cpp | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/passes/DeadArgumentElimination.cpp b/src/passes/DeadArgumentElimination.cpp index 7ba1be9f8..9d8fa5b0d 100644 --- a/src/passes/DeadArgumentElimination.cpp +++ b/src/passes/DeadArgumentElimination.cpp @@ -588,7 +588,8 @@ private: // In terms of parameters, we can do this. However, we must also check // local operations in the body, as if the parameter is reused and written // to, then those types must be taken into account as well. - for (auto* set : FindAll(func->body).list) { + FindAll sets(func->body); + for (auto* set : sets.list) { auto index = set->index; if (func->isParam(index) && !Type::isSubType(set->value->type, newParamTypes[index])) { @@ -602,7 +603,7 @@ private: return; } - // We can do this! Update the types, including the types of gets. + // We can do this! Update the types, including the types of gets and tees. func->setParams(newParams); for (auto* get : FindAll(func->body).list) { auto index = get->index; @@ -610,6 +611,16 @@ private: get->type = func->getLocalType(index); } } + for (auto* set : sets.list) { + auto index = set->index; + if (func->isParam(index) && set->isTee()) { + set->type = func->getLocalType(index); + set->finalize(); + } + } + + // Propagate the new get and set types outwards. + ReFinalize().walkFunctionInModule(func, module); } // See if the types returned from a function allow us to define a more refined diff --git a/src/passes/LocalSubtyping.cpp b/src/passes/LocalSubtyping.cpp index 9c6da1131..472463f44 100644 --- a/src/passes/LocalSubtyping.cpp +++ b/src/passes/LocalSubtyping.cpp @@ -134,8 +134,9 @@ struct LocalSubtyping : public WalkerPass> { // NB: These tee updates will not be needed if the type of tees // becomes that of their value, in the spec. for (auto* set : setsForLocal[i]) { - if (set->isTee() && set->type != Type::unreachable) { + if (set->isTee()) { set->type = newType; + set->finalize(); } } } -- cgit v1.2.3