diff options
| author | Luuk de Gram <luuk@degram.dev> | 2023-05-16 19:33:19 +0200 |
|---|---|---|
| committer | Luuk de Gram <luuk@degram.dev> | 2023-05-19 20:20:29 +0200 |
| commit | b93fa9833e6d2f7959eabb2417a154152a8d2d1c (patch) | |
| tree | 4ba806a2ca4684d1ae4db0c2e9f55eabcdca53c3 /src/arch/wasm/CodeGen.zig | |
| parent | 061d99285d5a73a71a97ed7bbb45f0a7f65acf2d (diff) | |
| download | zig-b93fa9833e6d2f7959eabb2417a154152a8d2d1c.tar.gz zig-b93fa9833e6d2f7959eabb2417a154152a8d2d1c.zip | |
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.
Diffstat (limited to 'src/arch/wasm/CodeGen.zig')
| -rw-r--r-- | src/arch/wasm/CodeGen.zig | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index d2a9d1a52f..2d0ee2fc69 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -4464,7 +4464,9 @@ fn airMemset(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void .One => @as(WValue, .{ .imm32 = @intCast(u32, ptr_ty.childType().arrayLen()) }), .C, .Many => unreachable, }; - try func.memset(ptr, len, value); + + const dst_ptr = try func.sliceOrArrayPtr(ptr, ptr_ty); + try func.memset(dst_ptr, len, value); func.finishAir(inst, .none, &.{ bin_op.lhs, bin_op.rhs }); } |
