From da8b071ba8c5cd290853188a6b7704417ca254eb Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 11 Apr 2024 12:10:10 -0700 Subject: [Parser] Use unreachables to fulfill tuple requirements (#6488) When we need to pop a tuple and the top value on the stack is unreachable, just pop the unreachable rather than producing a tuple.make. This always produces valid IR since an unreachable is always valid where a tuple would otherwise be expected. It also avoids bloating the parsed IR, since we would previously parse a `tuple.make` where all the children were unreachable in this case. --- src/wasm/wasm-ir-builder.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/wasm/wasm-ir-builder.cpp') diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp index 99462e9a8..7b88d345f 100644 --- a/src/wasm/wasm-ir-builder.cpp +++ b/src/wasm/wasm-ir-builder.cpp @@ -175,7 +175,9 @@ Result IRBuilder::pop(size_t size) { CHECK_ERR(packageHoistedValue(*hoisted, size)); auto* ret = scope.exprStack.back(); - if (ret->type.size() == size) { + // If the top value has the correct size, we can pop it and be done. + // Unreachable values satisfy any size. + if (ret->type.size() == size || ret->type == Type::unreachable) { scope.exprStack.pop_back(); return ret; } -- cgit v1.2.3