mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 00:35:10 +00:00
stage2-wasm: enable undef test + ignore undef store/memset with safety off
This commit is contained in:
parent
07f14bd43b
commit
58b38238f5
@ -2302,11 +2302,6 @@ fn airAlloc(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
|
||||
fn airStore(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {
|
||||
const pt = cg.pt;
|
||||
const zcu = pt.zcu;
|
||||
if (safety) {
|
||||
// TODO if the value is undef, write 0xaa bytes to dest
|
||||
} else {
|
||||
// TODO if the value is undef, don't lower this instruction
|
||||
}
|
||||
const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
|
||||
const lhs = try cg.resolveInst(bin_op.lhs);
|
||||
@ -2315,6 +2310,10 @@ fn airStore(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {
|
||||
const ptr_info = ptr_ty.ptrInfo(zcu);
|
||||
const ty = ptr_ty.childType(zcu);
|
||||
|
||||
if (!safety and bin_op.rhs == .undef) {
|
||||
return cg.finishAir(inst, .none, &.{ bin_op.lhs, bin_op.rhs });
|
||||
}
|
||||
|
||||
if (ptr_info.packed_offset.host_size == 0) {
|
||||
try cg.store(lhs, rhs, ty, 0);
|
||||
} else {
|
||||
@ -4756,11 +4755,6 @@ fn airPtrBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
|
||||
|
||||
fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {
|
||||
const zcu = cg.pt.zcu;
|
||||
if (safety) {
|
||||
// TODO if the value is undef, write 0xaa bytes to dest
|
||||
} else {
|
||||
// TODO if the value is undef, don't lower this instruction
|
||||
}
|
||||
const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
|
||||
const ptr = try cg.resolveInst(bin_op.lhs);
|
||||
@ -4777,6 +4771,10 @@ fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {
|
||||
else
|
||||
ptr_ty.childType(zcu);
|
||||
|
||||
if (!safety and bin_op.rhs == .undef) {
|
||||
return cg.finishAir(inst, .none, &.{ bin_op.lhs, bin_op.rhs });
|
||||
}
|
||||
|
||||
const dst_ptr = try cg.sliceOrArrayPtr(ptr, ptr_ty);
|
||||
try cg.memset(elem_ty, dst_ptr, len, value);
|
||||
|
||||
|
||||
@ -103,7 +103,6 @@ test "reslice of undefined global var slice" {
|
||||
test "returned undef is 0xaa bytes when runtime safety is enabled" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user