[Mlir-commits] [mlir] [MLIR][LLVM] LLVM import should use is isDSOLocal instead of hasLocalLinkage to set dso_local attribute (PR #124822)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Jan 28 12:46:16 PST 2025


https://github.com/ghehg updated https://github.com/llvm/llvm-project/pull/124822

>From 8eb4af9f6257eae171d465109dc62ff7f6cd9e41 Mon Sep 17 00:00:00 2001
From: Guojin He <he.guojin at gmail.com>
Date: Tue, 28 Jan 2025 14:06:22 -0500
Subject: [PATCH] [MLIR] should use dso_local

---
 mlir/lib/Target/LLVMIR/ModuleImport.cpp               | 2 +-
 mlir/test/Target/LLVMIR/Import/function-attributes.ll | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
index 40d86efe605ad0..414e000356c51f 100644
--- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
@@ -2106,7 +2106,7 @@ LogicalResult ModuleImport::processFunction(llvm::Function *func) {
       iface.isConvertibleIntrinsic(func->getIntrinsicID()))
     return success();
 
-  bool dsoLocal = func->hasLocalLinkage();
+  bool dsoLocal = func->isDSOLocal();
   CConv cconv = convertCConvFromLLVM(func->getCallingConv());
 
   // Insert the function at the end of the module.
diff --git a/mlir/test/Target/LLVMIR/Import/function-attributes.ll b/mlir/test/Target/LLVMIR/Import/function-attributes.ll
index 079aa6f90bf11d..cd9b7d9ffb138b 100644
--- a/mlir/test/Target/LLVMIR/Import/function-attributes.ll
+++ b/mlir/test/Target/LLVMIR/Import/function-attributes.ll
@@ -10,6 +10,12 @@ define internal spir_func void @spir_func_internal() {
   ret void
 }
 
+; Ensure that we have dso_local;
+; CHECK : llvm.func @dsolocal_func() attributes{dso_local}
+define dso_local void @dsolocal_func() {
+  ret void
+}
+
 ; // -----
 
 ; CHECK-LABEL: @func_readnone



More information about the Mlir-commits mailing list