[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
Thu Oct 17 07:07:43 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.
----------------
sunfishcode wrote:

Ah, it appears to be due to the `defm : BulkMemoryOps<...>`, which makes the opcodes "anonymous", and tablegen names their opcodes as `anonymous_9000MEMORY_COPY_A64` and `anonymous_9000MEMORY_COPY_A64` and `anonymous_9000MEMORY_FILL_A64`. If I change it to `defm : MEMORY_ : BulkMemoryOps<...>` and then remove the `MEMORY_` prefix from all the names, then they come out as just `MEMORY_COPY_A64` and `MEMORY_FILL_A64`.

I've now updated the code to use multiclasses for all instructions that have 32/64 variants.


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


More information about the llvm-commits mailing list