Commit a983f5b90f

Andrew Kelley <andrew@ziglang.org>
2025-07-08 06:09:13
wasm backend: memcpy and memmove are the same
both lower to memory.fill operation, which are allowed to overlap
1 parent c7b4b17
Changed files (2)
src
src/arch/wasm/CodeGen.zig
@@ -1959,7 +1959,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
         .wasm_memory_size => cg.airWasmMemorySize(inst),
         .wasm_memory_grow => cg.airWasmMemoryGrow(inst),
 
-        .memcpy => cg.airMemcpy(inst),
+        .memcpy, .memmove => cg.airMemcpy(inst),
 
         .ret_addr => cg.airRetAddr(inst),
         .tag_name => cg.airTagName(inst),
@@ -1983,7 +1983,6 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
         .c_va_copy,
         .c_va_end,
         .c_va_start,
-        .memmove,
         => |tag| return cg.fail("TODO: Implement wasm inst: {s}", .{@tagName(tag)}),
 
         .atomic_load => cg.airAtomicLoad(inst),
src/Air.zig
@@ -746,7 +746,9 @@ pub const Inst = struct {
         /// Dest slice may have any alignment; source pointer may have any alignment.
         /// The two memory regions must not overlap.
         /// Result type is always void.
+        ///
         /// Uses the `bin_op` field. LHS is the dest slice. RHS is the source pointer.
+        ///
         /// If the length is compile-time known (due to the destination or
         /// source being a pointer-to-array), then it is guaranteed to be
         /// greater than zero.
@@ -758,7 +760,9 @@ pub const Inst = struct {
         /// Dest slice may have any alignment; source pointer may have any alignment.
         /// The two memory regions may overlap.
         /// Result type is always void.
+        ///
         /// Uses the `bin_op` field. LHS is the dest slice. RHS is the source pointer.
+        ///
         /// If the length is compile-time known (due to the destination or
         /// source being a pointer-to-array), then it is guaranteed to be
         /// greater than zero.