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.
This commit is contained in:
Chris Fallin
2020-11-24 18:55:40 -08:00
parent 93c199363f
commit 34d9931ed8
3 changed files with 182 additions and 5 deletions

View File

@@ -514,7 +514,9 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
Operator::Return => {
let (return_count, br_destination) = {
let frame = &mut state.control_stack[0];
frame.set_branched_to_exit();
if environ.return_mode() == ReturnMode::FallthroughReturn {
frame.set_branched_to_exit();
}
let return_count = frame.num_return_values();
(return_count, frame.br_destination())
};