[llvm] [WebAssembly] validate `table.grow` correctly (PR #80437)

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 2 07:23:45 PST 2024


================
@@ -288,6 +288,16 @@ bool WebAssemblyAsmTypeCheck::typeCheck(SMLoc ErrorLoc, const MCInst &Inst,
       return true;
     if (popType(ErrorLoc, wasm::ValType::I32))
       return true;
+  } else if (Name == "table.size") {
+    if (getTable(Operands[1]->getStartLoc(), Inst, Type))
+      return true;
+    Stack.push_back(wasm::ValType::I32);
+  } else if (Name == "table.grow") {
+    if (getTable(Operands[1]->getStartLoc(), Inst, Type))
+      return true;
+    if (popType(ErrorLoc, wasm::ValType::I32))
+      return true;
+    Stack.push_back(wasm::ValType::I32);
----------------
sbc100 wrote:

Wow, this is pretty broken.

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


More information about the llvm-commits mailing list