machinst x64: fix index handling of jump table;
The index should be truncated to 32 bits before being used for the jump table entry computation.
This commit is contained in:
@@ -1336,7 +1336,7 @@ pub(crate) fn emit(
|
||||
// We generate the following sequence:
|
||||
// ;; generated by lowering: cmp #jmp_table_size, %idx
|
||||
// jnb $default_target
|
||||
// mov %idx, %tmp2
|
||||
// movl %idx, %tmp2
|
||||
// lea start_of_jump_table_offset(%rip), %tmp1
|
||||
// movzlq [%tmp1, %tmp2], %tmp2
|
||||
// addq %tmp2, %tmp1
|
||||
@@ -1349,7 +1349,8 @@ pub(crate) fn emit(
|
||||
};
|
||||
one_way_jmp(sink, CC::NB, *default_label); // idx unsigned >= jmp table size
|
||||
|
||||
let inst = Inst::gen_move(*tmp2, *idx, I64);
|
||||
// Copy the index (and make sure to clear the high 32-bits lane of tmp2).
|
||||
let inst = Inst::movzx_rm_r(ExtMode::LQ, RegMem::reg(*idx), *tmp2);
|
||||
inst.emit(sink, flags, state);
|
||||
|
||||
// Load base address of jump table.
|
||||
|
||||
Reference in New Issue
Block a user