[Mlir-commits] [mlir] 7fcc0f9 - Populate the llvm::GlobalVariable ELF section, with the attribute from the ObjectAttrs (#117246)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Nov 22 07:58:48 PST 2024


Author: Renaud Kauffmann
Date: 2024-11-22T07:58:45-08:00
New Revision: 7fcc0f9065727c2c3151f7103c9d2803e507c7b7

URL: https://github.com/llvm/llvm-project/commit/7fcc0f9065727c2c3151f7103c9d2803e507c7b7
DIFF: https://github.com/llvm/llvm-project/commit/7fcc0f9065727c2c3151f7103c9d2803e507c7b7.diff

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

Added: 
    

Modified: 
    mlir/lib/Target/LLVMIR/Dialect/GPU/SelectObjectAttr.cpp
    mlir/test/Target/LLVMIR/gpu.mlir

Removed: 
    


################################################################################
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<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);

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">]
+}


        


More information about the Mlir-commits mailing list