Skip to content

Commit d0bb505

Browse files
committed
ZJIT: Split Lea memory reads on x86_64
1 parent b9f1976 commit d0bb505

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

zjit/src/backend/x86_64/mod.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@ impl Assembler {
559559
asm.store(mem_out, SCRATCH0_OPND);
560560
}
561561
}
562-
Insn::Lea { out, .. } => {
562+
Insn::Lea { opnd, out } => {
563+
*opnd = split_stack_membase(asm, *opnd, SCRATCH0_OPND, &stack_state);
563564
let mem_out = split_memory_write(out, SCRATCH0_OPND);
564565
asm.push_insn(insn);
565566
if let Some(mem_out) = mem_out {
@@ -1804,4 +1805,20 @@ mod tests {
18041805
");
18051806
assert_snapshot!(cb.hexdump(), @"4c8b55f84c8b5df04d8b5b024d0f441a4c895df8");
18061807
}
1808+
1809+
#[test]
1810+
fn test_lea_split_memory_read() {
1811+
let (mut asm, mut cb) = setup_asm();
1812+
1813+
let opnd = Opnd::Mem(Mem { base: MemBase::Stack { stack_idx: 0, num_bits: 64 }, disp: 0, num_bits: 64 });
1814+
let _ = asm.lea(opnd);
1815+
asm.compile_with_num_regs(&mut cb, 0);
1816+
1817+
assert_disasm_snapshot!(cb.disasm(), @"
1818+
0x0: mov r11, qword ptr [rbp - 8]
1819+
0x4: lea r11, [r11]
1820+
0x7: mov qword ptr [rbp - 8], r11
1821+
");
1822+
assert_snapshot!(cb.hexdump(), @"4c8b5df84d8d1b4c895df8");
1823+
}
18071824
}

0 commit comments

Comments
 (0)