Bugfix: wrong jump arguments for br_if to loops
This commit is contained in:
@@ -499,8 +499,12 @@ fn translate_operator(op: &Operator,
|
||||
let val = stack.pop().unwrap();
|
||||
let i = control_stack.len() - 1 - (relative_depth as usize);
|
||||
let frame = &mut control_stack[i];
|
||||
let cut_index = stack.len() - frame.return_values().len();
|
||||
let jump_args = stack.split_off(cut_index);
|
||||
let jump_args = if frame.is_loop() {
|
||||
Vec::new()
|
||||
} else {
|
||||
let cut_index = stack.len() - frame.return_values().len();
|
||||
stack.split_off(cut_index)
|
||||
};
|
||||
builder
|
||||
.ins()
|
||||
.brnz(val, frame.br_destination(), jump_args.as_slice());
|
||||
@@ -517,9 +521,15 @@ fn translate_operator(op: &Operator,
|
||||
min_depth = *depth;
|
||||
}
|
||||
}
|
||||
let jump_args_count = control_stack[control_stack.len() - 1 - (min_depth as usize)]
|
||||
.return_values()
|
||||
.len();
|
||||
let jump_args_count = {
|
||||
let i = control_stack.len() - 1 - (min_depth as usize);
|
||||
let min_depth_frame = &control_stack[i];
|
||||
if min_depth_frame.is_loop() {
|
||||
0
|
||||
} else {
|
||||
min_depth_frame.return_values().len()
|
||||
}
|
||||
};
|
||||
if jump_args_count == 0 {
|
||||
// No jump arguments
|
||||
let val = stack.pop().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user