diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp @@ -1269,7 +1269,8 @@ matchAndRewrite(spirv::ModuleOp spvModuleOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { - auto newModuleOp = rewriter.create(spvModuleOp.getLoc()); + auto newModuleOp = + rewriter.create(spvModuleOp.getLoc(), spvModuleOp.getName()); rewriter.inlineRegionBefore(spvModuleOp.body(), newModuleOp.getBody()); // Remove the terminator block that was automatically added by builder diff --git a/mlir/test/Conversion/SPIRVToLLVM/module-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/module-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/module-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/module-ops-to-llvm.mlir @@ -7,6 +7,9 @@ // CHECK: module spv.module Logical GLSL450 {} +// CHECK: module @foo +spv.module @foo Logical GLSL450 {} + // CHECK: module spv.module Logical GLSL450 requires #spv.vce {}