From ca27f40a2f1070a16ee7c0efc18ff35d342d8027 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Thu, 1 Jul 2021 01:56:23 +0000 Subject: Preserve Function HeapTypes (#3952) When using nominal types, func.ref of two functions with identical signatures but different HeapTypes will yield different types. To preserve these semantics, Functions need to track their HeapTypes, not just their Signatures. This PR replaces the Signature field in Function with a HeapType field and adds new utility methods to make it almost as simple to update and query the function HeapType as it was to update and query the Function Signature. --- src/passes/ReReloop.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/passes/ReReloop.cpp') diff --git a/src/passes/ReReloop.cpp b/src/passes/ReReloop.cpp index 9a82d8b44..0559343d4 100644 --- a/src/passes/ReReloop.cpp +++ b/src/passes/ReReloop.cpp @@ -318,7 +318,7 @@ struct ReReloop final : public Pass { for (auto& cfgBlock : relooper->Blocks) { auto* block = cfgBlock->Code->cast(); if (cfgBlock->BranchesOut.empty() && block->type != Type::unreachable) { - block->list.push_back(function->sig.results == Type::none + block->list.push_back(function->getResults() == Type::none ? (Expression*)builder->makeReturn() : (Expression*)builder->makeUnreachable()); block->finalize(); @@ -351,7 +351,7 @@ struct ReReloop final : public Pass { // because of the relooper's boilerplate switch-handling // code, for example, which could be optimized out later // but isn't yet), then make sure it has a proper type - if (function->sig.results != Type::none && + if (function->getResults() != Type::none && function->body->type == Type::none) { function->body = builder.makeSequence(function->body, builder.makeUnreachable()); -- cgit v1.2.3