mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 13:58:27 +00:00
x86_64: fix packedStore miscomp by spilling EFLAGS
Fixes #20113 and #20581. AND instructions in packedStore clobbers EFLAGS. Bug: https://github.com/ziglang/zig/issues/20113 Bug: https://github.com/ziglang/zig/issues/20581 Signed-off-by: Bingwu Zhang <xtex@aosc.io>
This commit is contained in:
parent
9c9d3931df
commit
c62fb118e7
@ -88178,12 +88178,15 @@ fn airStore(self: *CodeGen, inst: Air.Inst.Index, safety: bool) !void {
|
||||
const reg_locks = self.register_manager.lockRegsAssumeUnused(3, .{ .rdi, .rsi, .rcx });
|
||||
defer for (reg_locks) |lock| self.register_manager.unlockReg(lock);
|
||||
|
||||
const ptr_ty = self.typeOf(bin_op.lhs);
|
||||
const ptr_info = ptr_ty.ptrInfo(zcu);
|
||||
const is_packed = ptr_info.flags.vector_index != .none or ptr_info.packed_offset.host_size > 0;
|
||||
if (is_packed) try self.spillEflagsIfOccupied();
|
||||
|
||||
const src_mcv = try self.resolveInst(bin_op.rhs);
|
||||
const ptr_mcv = try self.resolveInst(bin_op.lhs);
|
||||
const ptr_ty = self.typeOf(bin_op.lhs);
|
||||
|
||||
const ptr_info = ptr_ty.ptrInfo(zcu);
|
||||
if (ptr_info.flags.vector_index != .none or ptr_info.packed_offset.host_size > 0) {
|
||||
if (is_packed) {
|
||||
try self.packedStore(ptr_ty, ptr_mcv, src_mcv);
|
||||
} else {
|
||||
try self.store(ptr_ty, ptr_mcv, src_mcv, .{ .safety = safety });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user