Skip to content

Commit 7fcc0f9

Browse files
authored
Populate the llvm::GlobalVariable ELF section, with the attribute from the ObjectAttrs (#117246)
1 parent c4aa838 commit 7fcc0f9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

mlir/lib/Target/LLVMIR/Dialect/GPU/SelectObjectAttr.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ LogicalResult SelectObjectAttrImpl::embedBinary(
121121
new llvm::GlobalVariable(*module, binary->getType(), true,
122122
llvm::GlobalValue::LinkageTypes::InternalLinkage,
123123
binary, getBinaryIdentifier(op.getName()));
124+
125+
if (object.getProperties()) {
126+
if (auto section = mlir::dyn_cast_or_null<mlir::StringAttr>(
127+
object.getProperties().get("section"))) {
128+
serializedObj->setSection(section.getValue());
129+
}
130+
}
124131
serializedObj->setLinkage(llvm::GlobalValue::LinkageTypes::InternalLinkage);
125132
serializedObj->setAlignment(llvm::MaybeAlign(8));
126133
serializedObj->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::None);

mlir/test/Target/LLVMIR/gpu.mlir

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,11 @@ module attributes {gpu.container_module} {
101101
llvm.return
102102
}
103103
}
104+
105+
// -----
106+
107+
// Checking that ELF section is populated
108+
module attributes {gpu.container_module} {
109+
// CHECK: @cuda_device_mod_bin_cst = internal constant [4 x i8] c"BLOB", section "__nv_rel_fatbin", align 8
110+
gpu.binary @cuda_device_mod [#gpu.object<#nvvm.target, properties = {section = "__nv_rel_fatbin"}, "BLOB">]
111+
}

0 commit comments

Comments
 (0)