[Mlir-commits] [mlir] [mlir][spirv] Remove destroyed values from ValueIDMap (PR #164098)

Jakub Kuderski llvmlistbot at llvm.org
Sat Oct 18 12:15:06 PDT 2025


================
@@ -311,6 +311,15 @@ LogicalResult Serializer::processFuncOp(spirv::FuncOp op) {
     op.addEntryBlock();
     if (failed(processFuncParameter(op)))
       return failure();
+
+    // Erasing the body of the function destroys arguments, so we need to remove
+    // them from the map to avoid problems when processing invalid values used
+    // as keys. We have already serialized function arguments so we probably can
+    // remove them from the map as external function will not have any uses.
+    for (Value arg : op.getArguments())
+      if (valueIDMap.count(arg))
+        valueIDMap.erase(arg);
----------------
kuhar wrote:

actually, you can erase without checking if the key is in the map

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


More information about the Mlir-commits mailing list