Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix implicit br return #2324

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 6 additions & 2 deletions include/wabt/decompiler-ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,12 @@ struct AST {
return;
}
case ExprType::Br: {
InsertNode(NodeType::Expr, ExprType::Br, &e, 0).u.lt =
mc.GetLabel(cast<BrExpr>(&e)->var)->label_type;
LabelType lt = mc.GetLabel(cast<BrExpr>(&e)->var)->label_type;
if (lt == LabelType::Func) {
InsertNode(NodeType::Expr, ExprType::Return, &e, arity.nargs);
return;
}
InsertNode(NodeType::Expr, ExprType::Br, &e, 0).u.lt = lt;
return;
}
case ExprType::BrIf: {
Expand Down
12 changes: 12 additions & 0 deletions test/decompile/br_return.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
;;; TOOL: run-wasm-decompile

(module
(func $f (result i32) i32.const 10 br 0)
)

(;; STDOUT ;;;
function f_a():int {
return 10
}

;;; STDOUT ;;)
Loading