summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-03-05 14:37:46 -0800
committerGitHub <noreply@github.com>2024-03-05 14:37:46 -0800
commit71bf4b3fa2716d5c54e04f7e76c2463b1adddeae (patch)
treeeb1bc867c7b561387d685ea4ae457d8e1755c3a8 /src
parentd1a7d4b8c8965a1f1c4bb22510631c28334581cb (diff)
downloadbinaryen-71bf4b3fa2716d5c54e04f7e76c2463b1adddeae.tar.gz
binaryen-71bf4b3fa2716d5c54e04f7e76c2463b1adddeae.tar.bz2
binaryen-71bf4b3fa2716d5c54e04f7e76c2463b1adddeae.zip
[Parser] Improve parsed IR for multivalue returns (#6378)
Rather than reassembling a tuple from multiple pops, let the pop implementation assemble the tuple. This produces less code in cases where there is already a tuple of the proper size on top of the stack. It also simplifies the code.
Diffstat (limited to 'src')
-rw-r--r--src/wasm/wasm-ir-builder.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp
index ffd0b8674..a7c743970 100644
--- a/src/wasm/wasm-ir-builder.cpp
+++ b/src/wasm/wasm-ir-builder.cpp
@@ -378,18 +378,10 @@ Result<> IRBuilder::visitReturn(Return* curr) {
size_t n = func->getResults().size();
if (n == 0) {
curr->value = nullptr;
- } else if (n == 1) {
- auto val = pop();
+ } else {
+ auto val = pop(n);
CHECK_ERR(val);
curr->value = *val;
- } else {
- std::vector<Expression*> vals(n);
- for (size_t i = 0; i < n; ++i) {
- auto val = pop();
- CHECK_ERR(val);
- vals[n - i - 1] = *val;
- }
- curr->value = builder.makeTupleMake(vals);
}
return Ok{};
}