[llvm] [WebAssembly] Protect memory.fill and memory.copy from zero-length ranges. (PR #112617)
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 23 11:53:34 PDT 2024
================
@@ -21,22 +21,37 @@ multiclass BULK_I<dag oops_r, dag iops_r, dag oops_s, dag iops_s,
}
// Bespoke types and nodes for bulk memory ops
-def wasm_memcpy_t : SDTypeProfile<0, 5,
+
+def wasm_memcpylike_t : SDTypeProfile<0, 5,
[SDTCisInt<0>, SDTCisInt<1>, SDTCisPtrTy<2>, SDTCisPtrTy<3>, SDTCisInt<4>]
>;
-def wasm_memcpy : SDNode<"WebAssemblyISD::MEMORY_COPY", wasm_memcpy_t,
- [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
-
-def wasm_memset_t : SDTypeProfile<0, 4,
+def wasm_memsetlike_t : SDTypeProfile<0, 4,
[SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisInt<2>, SDTCisInt<3>]
>;
-def wasm_memset : SDNode<"WebAssemblyISD::MEMORY_FILL", wasm_memset_t,
+
+// memory.copy (may trap on empty ranges)
+def wasm_memory_copy : SDNode<"WebAssemblyISD::MEMORY_COPY", wasm_memcpylike_t,
+ [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
----------------
sunfishcode wrote:
Done.
https://github.com/llvm/llvm-project/pull/112617
More information about the llvm-commits
mailing list