diff --git a/mlir/lib/Target/LLVMIR/Dialect/GPU/SelectObjectAttr.cpp b/mlir/lib/Target/LLVMIR/Dialect/GPU/SelectObjectAttr.cpp index b023c4c126da30..3aeadeb283ff69 100644 --- a/mlir/lib/Target/LLVMIR/Dialect/GPU/SelectObjectAttr.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/GPU/SelectObjectAttr.cpp @@ -121,6 +121,13 @@ LogicalResult SelectObjectAttrImpl::embedBinary( new llvm::GlobalVariable(*module, binary->getType(), true, llvm::GlobalValue::LinkageTypes::InternalLinkage, binary, getBinaryIdentifier(op.getName())); + + if (object.getProperties()) { + if (auto section = mlir::dyn_cast_or_null( + object.getProperties().get("section"))) { + serializedObj->setSection(section.getValue()); + } + } serializedObj->setLinkage(llvm::GlobalValue::LinkageTypes::InternalLinkage); serializedObj->setAlignment(llvm::MaybeAlign(8)); serializedObj->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::None); diff --git a/mlir/test/Target/LLVMIR/gpu.mlir b/mlir/test/Target/LLVMIR/gpu.mlir index 0f41f0b1a59d12..6b7e7fcc71960d 100644 --- a/mlir/test/Target/LLVMIR/gpu.mlir +++ b/mlir/test/Target/LLVMIR/gpu.mlir @@ -101,3 +101,11 @@ module attributes {gpu.container_module} { llvm.return } } + +// ----- + +// Checking that ELF section is populated +module attributes {gpu.container_module} { + // CHECK: @cuda_device_mod_bin_cst = internal constant [4 x i8] c"BLOB", section "__nv_rel_fatbin", align 8 + gpu.binary @cuda_device_mod [#gpu.object<#nvvm.target, properties = {section = "__nv_rel_fatbin"}, "BLOB">] +}