[Mlir-commits] [mlir] 7b61b19 - [MLIR][SPIRV] Create new ctx for deserialization in roundtrips.
Lei Zhang
llvmlistbot at llvm.org
Fri Sep 18 08:54:02 PDT 2020
Author: ergawy
Date: 2020-09-18T11:53:51-04:00
New Revision: 7b61b192753360427fade9c9c5b68cd76adfc665
URL: https://github.com/llvm/llvm-project/commit/7b61b192753360427fade9c9c5b68cd76adfc665
DIFF: https://github.com/llvm/llvm-project/commit/7b61b192753360427fade9c9c5b68cd76adfc665.diff
LOG: [MLIR][SPIRV] Create new ctx for deserialization in roundtrips.
Roundtripping SPIR-V modules used the same MLIRContext object for both
ways of the trip. This resulted in deserialization using a context
object already containing Types constructed during serialization.
This commit rectifies that by creating a new MLIRContext during
deserialization.
Reviewed By: mravishankar, antiagainst
Differential Revision: https://reviews.llvm.org/D87692
Added:
Modified:
mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp b/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp
index 8a6032f8f417..ee2a1e436446 100644
--- a/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp
+++ b/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp
@@ -136,14 +136,17 @@ static LogicalResult roundTripModule(ModuleOp srcModule, bool emitDebugInfo,
if (failed(spirv::serialize(*spirvModules.begin(), binary, emitDebugInfo)))
return failure();
+ MLIRContext deserializationContext(false);
+ context->getDialectRegistry().loadAll(&deserializationContext);
// Then deserialize to get back a SPIR-V module.
- spirv::OwningSPIRVModuleRef spirvModule = spirv::deserialize(binary, context);
+ spirv::OwningSPIRVModuleRef spirvModule =
+ spirv::deserialize(binary, &deserializationContext);
if (!spirvModule)
return failure();
// Wrap around in a new MLIR module.
OwningModuleRef dstModule(ModuleOp::create(FileLineColLoc::get(
- /*filename=*/"", /*line=*/0, /*column=*/0, context)));
+ /*filename=*/"", /*line=*/0, /*column=*/0, &deserializationContext)));
dstModule->getBody()->push_front(spirvModule.release());
dstModule->print(output);
More information about the Mlir-commits
mailing list