Skip to content

Populate the llvm::GlobalVariable ELF section, with the attribute from the ObjectAttrs #117246

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
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions mlir/lib/Target/LLVMIR/Dialect/GPU/SelectObjectAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<mlir::StringAttr>(
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);
Expand Down
8 changes: 8 additions & 0 deletions mlir/test/Target/LLVMIR/gpu.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -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">]
}
Loading