[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 11:12:09 PST 2025
https://github.com/ghehg created https://github.com/llvm/llvm-project/pull/124822
Function definitions mostly have external linkage thus would be missing dso_local attribute during translation.
>From 7a9ef107b5d2550087781a2900ee6ec0f82778f6 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 +-
.../LLVMIR/Import/function-attributes-generic.ll | 10 ++++++++++
2 files changed, 11 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-generic.ll b/mlir/test/Target/LLVMIR/Import/function-attributes-generic.ll
index d7f8400413b896..a3cf048441e0d5 100644
--- a/mlir/test/Target/LLVMIR/Import/function-attributes-generic.ll
+++ b/mlir/test/Target/LLVMIR/Import/function-attributes-generic.ll
@@ -7,3 +7,13 @@
; CHECK-NOT: res_attrs
; CHECK-SAME: }>
declare ptr @func_no_param_attrs()
+
+; Ensure that we have dso_local
+; CHECK: "llvm.func"()
+; CHECK-SAME: <{
+; CHECK-SAME: dso_local
+; CHECK-SAME: "dsolocal_func"
+; CHECK-SAME: }>
+define dso_local void @dsolocal_func() {
+ ret void
+}
More information about the Mlir-commits
mailing list