Skip to content

[mlir][spirv] Fix int type declaration duplication when serializing #143108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions mlir/lib/Target/SPIRV/Serialization/Serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,19 @@ LogicalResult Serializer::processType(Location loc, Type type,
LogicalResult
Serializer::processTypeImpl(Location loc, Type type, uint32_t &typeID,
SetVector<StringRef> &serializationCtx) {

// Map unisgned integer types to singless integer types
// This is needed otherwise the generated spirv assembly will contain
// twice a type declaration (like OpTypeInt 32 0) which is no permitted and
// such module could no pass validation. Indeed at MLIR level the two types
// are different and lookup in the cache below fails.
// Note: This convertion needs to happen here before the type is looked up in
// the cache
if (type.isUnsignedInteger()) {
type = IntegerType::get(loc->getContext(), type.getIntOrFloatBitWidth(),
IntegerType::SignednessSemantics::Signless);
}

typeID = getTypeID(type);
if (typeID)
return success();
Expand Down
Loading