Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/wasm/wasm-ir-builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ Result<Expression*> 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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From your description I thought this was for tuples, but ret->type.size() == size can be the case for non-tuples too, can't it? (when size == 1)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but since we report the size of Type::unreachable as 1, this code path was already taken for singular unreachable popped values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks. Maybe worth a comment?

scope.exprStack.pop_back();
return ret;
}
Expand Down
5 changes: 1 addition & 4 deletions test/lit/wat-kitchen-sink.wast
Original file line number Diff line number Diff line change
Expand Up @@ -3652,10 +3652,7 @@
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
;; CHECK-NEXT: (return
;; CHECK-NEXT: (tuple.make 2
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $return-two-second-unreachable (param i32) (result i32 i64)
Expand Down