authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2023-05-16 19:33:19+02:00
committergravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2023-05-19 20:20:29+02:00
logb93fa9833e6d2f7959eabb2417a154152a8d2d1c
tree4ba806a2ca4684d1ae4db0c2e9f55eabcdca53c3
parent061d99285d5a73a71a97ed7bbb45f0a7f65acf2d
signaturelock-open Commit is signed but in an unrecognized format.

wasm: memset - correctly load the ptr for slices

Previously we would use the address of the slice itself, which would result in miscompilations and accidently setting the memory region of the slice itself, rather than based on the `ptr` field.

1 files changed, 3 insertions(+), 1 deletions(-)

src/arch/wasm/CodeGen.zig+3-1
......@@ -4464,7 +4464,9 @@ fn airMemset(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void
44644464 .One => @as(WValue, .{ .imm32 = @intCast(u32, ptr_ty.childType().arrayLen()) }),
44654465 .C, .Many => unreachable,
44664466 };
4467 try func.memset(ptr, len, value);
4467
4468 const dst_ptr = try func.sliceOrArrayPtr(ptr, ptr_ty);
4469 try func.memset(dst_ptr, len, value);
44684470
44694471 func.finishAir(inst, .none, &.{ bin_op.lhs, bin_op.rhs });
44704472}