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
2 changes: 1 addition & 1 deletion src/passes/TranslateEH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ struct TranslateToNewEH : public WalkerPass<PostWalker<TranslateToNewEH>> {
// )
// )
Expression* innerBody = nullptr;
if (func->body->type.isConcrete()) {
if (func->getResults().isConcrete()) {
auto* ret = builder.makeReturn(func->body);
innerBody = builder.blockifyWithName(
ret, callerDelegateBrTarget, nullptr, Type(HeapType::exn, Nullable));
Expand Down
45 changes: 45 additions & 0 deletions test/lit/passes/translate-to-new-eh.wast
Original file line number Diff line number Diff line change
Expand Up @@ -2125,4 +2125,49 @@
(delegate 0)
)
)

;; CHECK: (func $throw_ref-in-resultless-block (type $2) (result i32)
;; CHECK-NEXT: (throw_ref
;; CHECK-NEXT: (block $__binaryen_delegate_caller_target0 (result exnref)
;; CHECK-NEXT: (return
;; CHECK-NEXT: (block
;; CHECK-NEXT: (try_table (catch_all_ref $__binaryen_delegate_caller_target0)
;; CHECK-NEXT: (call $foo)
;; CHECK-NEXT: )
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; STACKIR-OPT: (func $throw_ref-in-resultless-block (type $2) (result i32)
;; STACKIR-OPT-NEXT: block $__binaryen_delegate_caller_target0 (result exnref)
;; STACKIR-OPT-NEXT: try_table (catch_all_ref $__binaryen_delegate_caller_target0)
;; STACKIR-OPT-NEXT: call $foo
;; STACKIR-OPT-NEXT: end
;; STACKIR-OPT-NEXT: unreachable
;; STACKIR-OPT-NEXT: end
;; STACKIR-OPT-NEXT: throw_ref
;; STACKIR-OPT-NEXT: )
(func $throw_ref-in-resultless-block (result i32)
;; When the function return type is concrete, try-delegate that targets the
;; caller is translated to
;; (throw_ref
;; (block $__binaryen_delegate_caller_target (result exnref)
;; (return
;; function body
;; )
;; )
;; )
;; We should do that even if the function body's type is not concrete.
(block ;; This block doesn't have concrete result type
(try
(do
(call $foo)
)
(delegate 1)
)
(unreachable)
)
)
)