[Mlir-commits] [mlir] Populate the llvm::GlobalVariable ELF section, with the attribute from the ObjectAttrs (PR #117246)
Renaud Kauffmann
llvmlistbot at llvm.org
Thu Nov 21 14:02:36 PST 2024
https://github.com/Renaud-K created https://github.com/llvm/llvm-project/pull/117246
None
>From fa144ca78374b04ac3e86377ab9214bc7e612a81 Mon Sep 17 00:00:00 2001
From: Renaud-K <rkauffmann at nvidia.com>
Date: Thu, 21 Nov 2024 13:59:26 -0800
Subject: [PATCH] Specifying ELF section on llvm::GlobalVariable if ObjectAttr
attribute exists
---
mlir/lib/Target/LLVMIR/Dialect/GPU/SelectObjectAttr.cpp | 7 +++++++
1 file changed, 7 insertions(+)
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);
More information about the Mlir-commits
mailing list