[llvm] [WebAssembly] Protect memory.fill and memory.copy from zero-length ranges. (PR #112617)

Heejin Ahn via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 17 00:15:14 PDT 2024


================
@@ -51,25 +68,83 @@ defm DATA_DROP :
          [],
          "data.drop\t$seg", "data.drop\t$seg", 0x09>;
 
+}
+
+defm : BulkMemoryOps<I32, "32">;
+defm : BulkMemoryOps<I64, "64">;
+
+// Define copy/fill manually instead of using the `BulkMemoryOps` multiclass
+// because when a multiclass defines opcodes, it gives them anonymous names
+// and we need opcodes with names so that we can handle them with custom code.
----------------
aheejin wrote:

Not sure what this means. We use all opcodes in code by `WebAssembly::INSTRNAME` and most of them all inherit from some multiclass..? For example, this is from `LowerFPToInt`:
https://github.com/llvm/llvm-project/blob/27f66c9a84bc72acc2536013e08ea0a11161e81b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp#L481-L487
All instructions here inherit from some multiclass. For example, `ABS_F32` inherits from the multiclass `UNARY_FP`, and we can use their names fine:
https://github.com/llvm/llvm-project/blob/267be4a7f4ac69cfd1bec5223554bbe400c5636c/llvm/lib/Target/WebAssembly/WebAssemblyInstrFloat.td#L55

Am I missing something?

https://github.com/llvm/llvm-project/pull/112617


More information about the llvm-commits mailing list