Skip to content

Commit 2b76b5b

Browse files
committed
Fix Wasm translator bug: end of toplevel frame is branched-to only for fallthrough returns.
This makes the value of `state.reachable()` inaccurate when observing at the tail of functions (in the post-function hook) after an ordinary return instruction.
1 parent 93c1993 commit 2b76b5b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cranelift/wasm/src/code_translator.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,9 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
514514
Operator::Return => {
515515
let (return_count, br_destination) = {
516516
let frame = &mut state.control_stack[0];
517-
frame.set_branched_to_exit();
517+
if environ.return_mode() == ReturnMode::FallthroughReturn {
518+
frame.set_branched_to_exit();
519+
}
518520
let return_count = frame.num_return_values();
519521
(return_count, frame.br_destination())
520522
};

0 commit comments

Comments
 (0)