From bcc76146fed433cbc8ba01a9f568d979c145110b Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Mon, 30 Dec 2019 17:55:20 -0800 Subject: Add support for reference types proposal (#2451) This adds support for the reference type proposal. This includes support for all reference types (`anyref`, `funcref`(=`anyfunc`), and `nullref`) and four new instructions: `ref.null`, `ref.is_null`, `ref.func`, and new typed `select`. This also adds subtype relationship support between reference types. This does not include table instructions yet. This also does not include wasm2js support. Fixes #2444 and fixes #2447. --- src/passes/SimplifyLocals.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/passes/SimplifyLocals.cpp') diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp index a3fa4a34d..a952f8a38 100644 --- a/src/passes/SimplifyLocals.cpp +++ b/src/passes/SimplifyLocals.cpp @@ -546,7 +546,6 @@ struct SimplifyLocals auto* blockLocalSetPointer = sinkables.at(sharedIndex).item; auto* value = (*blockLocalSetPointer)->template cast()->value; block->list[block->list.size() - 1] = value; - block->type = value->type; ExpressionManipulator::nop(*blockLocalSetPointer); for (size_t j = 0; j < breaks.size(); j++) { // move break local.set's value to the break @@ -577,6 +576,7 @@ struct SimplifyLocals this->replaceCurrent(newLocalSet); sinkables.clear(); anotherCycle = true; + block->finalize(); } // optimize local.sets from both sides of an if into a return value @@ -915,6 +915,7 @@ struct SimplifyLocals void visitLocalSet(LocalSet* curr) { // Remove trivial copies, even through a tee auto* value = curr->value; + Function* func = this->getFunction(); while (auto* subSet = value->dynCast()) { value = subSet->value; } @@ -929,7 +930,8 @@ struct SimplifyLocals } anotherCycle = true; } - } else { + } else if (func->getLocalType(curr->index) == + func->getLocalType(get->index)) { // There is a new equivalence now. equivalences.reset(curr->index); equivalences.add(curr->index, get->index); -- cgit v1.2.3