[Mlir-commits] [mlir] e59cdcd - [mlir][spirv] Allow unnamed entry point functions

Lei Zhang llvmlistbot at llvm.org
Mon Jul 18 09:03:46 PDT 2022


Author: Alexander Batashev
Date: 2022-07-18T12:03:38-04:00
New Revision: e59cdcd070249488c5c5de668bb84a3033ab62c9

URL: https://github.com/llvm/llvm-project/commit/e59cdcd070249488c5c5de668bb84a3033ab62c9
DIFF: https://github.com/llvm/llvm-project/commit/e59cdcd070249488c5c5de668bb84a3033ab62c9.diff

LOG: [mlir][spirv] Allow unnamed entry point functions

SPIR-V specification does not require a function to have a name
if it is an entry point. Adjust deserializer to allow those kinds
of SPIR-V binaries.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D120181

Added: 
    

Modified: 
    mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
index 1db8e95b084d7..9566b9ed1bbe8 100644
--- a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
@@ -347,9 +347,15 @@ Deserializer::processOp<spirv::EntryPointOp>(ArrayRef<uint32_t> words) {
     return emitError(unknownLoc, "no function matching <id> ") << fnID;
   }
   if (parsedFunc.getName() != fnName) {
-    return emitError(unknownLoc, "function name mismatch between OpEntryPoint "
-                                 "and OpFunction with <id> ")
-           << fnID << ": " << fnName << " vs. " << parsedFunc.getName();
+    // The deserializer uses "spirv_fn_<id>" as the function name if the input
+    // SPIR-V blob does not contain a name for it. We should use a more clear
+    // indication for such case rather than relying on naming details.
+    if (!parsedFunc.getName().startswith("spirv_fn_"))
+      return emitError(unknownLoc,
+                       "function name mismatch between OpEntryPoint "
+                       "and OpFunction with <id> ")
+             << fnID << ": " << fnName << " vs. " << parsedFunc.getName();
+    parsedFunc.setName(fnName);
   }
   SmallVector<Attribute, 4> interface;
   while (wordIndex < words.size()) {


        


More information about the Mlir-commits mailing list