diff --git a/cranelift/wasm/src/code_translator.rs b/cranelift/wasm/src/code_translator.rs index 4416410664..4b6eb8ed32 100644 --- a/cranelift/wasm/src/code_translator.rs +++ b/cranelift/wasm/src/code_translator.rs @@ -203,6 +203,7 @@ pub fn translate_operator( else_data: ElseData::NoElse { branch_inst }, ref mut reachable_from_top, blocktype, + destination, .. } => { // We take the control frame pushed by the if, use its ebb @@ -215,7 +216,7 @@ pub fn translate_operator( let (params, _results) = blocktype_params_results(wasm_types, blocktype)?; let else_ebb = ebb_with_params(builder, params)?; - builder.ins().jump(else_ebb, state.peekn(params.len())); + builder.ins().jump(destination, state.peekn(params.len())); state.popn(params.len()); // You might be expecting that we push the parameters for this diff --git a/cranelift/wasmtests/multi-16.wat b/cranelift/wasmtests/multi-16.wat new file mode 100644 index 0000000000..1e60aa8cc8 --- /dev/null +++ b/cranelift/wasmtests/multi-16.wat @@ -0,0 +1,9 @@ +(module + (func (export "param") (param i32) (result i32) + (i32.const 1) + (if (param i32) (result i32) (local.get 0) + (then (i32.const 2) (i32.add)) + (else (i32.const -2) (i32.add)) + ) + ) +)