[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
This commit is contained in:
Alexander Batashev 2022-07-18 11:56:34 -04:00 committed by Lei Zhang
parent 3e21fb616d
commit e59cdcd070

View File

@ -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()) {