summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-ir-builder.cpp
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-02-07 17:34:47 -0800
committerGitHub <noreply@github.com>2024-02-07 17:34:47 -0800
commit0724babd6c1b7fa5891f1de2cc60228734bc4395 (patch)
tree278b08fb50e53181043b70f96f4acabd67bf71e7 /src/wasm/wasm-ir-builder.cpp
parent4e0796d022fcd48c8af5a8a709577ce495bca991 (diff)
downloadbinaryen-0724babd6c1b7fa5891f1de2cc60228734bc4395.tar.gz
binaryen-0724babd6c1b7fa5891f1de2cc60228734bc4395.tar.bz2
binaryen-0724babd6c1b7fa5891f1de2cc60228734bc4395.zip
[Parser] Do not involve IRBuilder for imported functions (#6286)
We previously had a bug where we would begin and end an IRBuilder context for imported functions even though they don't have bodies. For functions that return results, ending this empty scope should have produced an error except that we had another bug where we only produced that error for multivalue functions. We did not previously have imported multivalue functions in wat-kitchen-sink.wast, so both of these bugs went undetected. Fix both bugs and update the test to include an imported multivalue function so that it would have failed without this fix.
Diffstat (limited to 'src/wasm/wasm-ir-builder.cpp')
-rw-r--r--src/wasm/wasm-ir-builder.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp
index 8098856e4..bf3c38c1e 100644
--- a/src/wasm/wasm-ir-builder.cpp
+++ b/src/wasm/wasm-ir-builder.cpp
@@ -162,7 +162,6 @@ Result<Expression*> IRBuilder::pop(size_t size) {
// Find the suffix of expressions that do not produce values.
auto hoisted = hoistLastValue();
CHECK_ERR(hoisted);
-
if (!hoisted) {
// There are no expressions that produce values.
if (scope.unreachable) {
@@ -700,6 +699,9 @@ Result<Expression*> IRBuilder::finishScope(Block* block) {
// the top.
auto hoisted = hoistLastValue();
CHECK_ERR(hoisted);
+ if (!hoisted) {
+ return Err{"popping from empty stack"};
+ }
}
Expression* ret = nullptr;