aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuojin <he.guojin@gmail.com>2025-01-29 11:09:18 -0500
committerGitHub <noreply@github.com>2025-01-29 17:09:18 +0100
commit4fc514af516f9434bf5ba3de404943a1f92817f7 (patch)
treeec307c964f95e740a92de4b829ac7bd2192d3e6c
parent382d3599c203573388b82717dc17e3db4039916a (diff)
downloadllvm-4fc514af516f9434bf5ba3de404943a1f92817f7.zip
llvm-4fc514af516f9434bf5ba3de404943a1f92817f7.tar.gz
llvm-4fc514af516f9434bf5ba3de404943a1f92817f7.tar.bz2
[MLIR][LLVM] Fix import of dso_local attribute (#124822)
The import of LLVM IR should use is isDSOLocal instead of hasLocalLinkage to set the dso_local attribute. Without this change, function definitions that mostly have external linkage would be missing dso_local attribute during translation. --------- Co-authored-by: Tobias Gysi <tobias.gysi@nextsilicon.com>
-rw-r--r--mlir/lib/Target/LLVMIR/ModuleImport.cpp2
-rw-r--r--mlir/test/Target/LLVMIR/Import/function-attributes.ll9
2 files changed, 10 insertions, 1 deletions
diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
index 838e343..1d1a985 100644
--- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
@@ -2139,7 +2139,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 203c570..beda421 100644
--- a/mlir/test/Target/LLVMIR/Import/function-attributes.ll
+++ b/mlir/test/Target/LLVMIR/Import/function-attributes.ll
@@ -12,6 +12,15 @@ define internal spir_func void @spir_func_internal() {
; // -----
+; Ensure that we have dso_local.
+; CHECK: llvm.func @dsolocal_func()
+; CHECK-SAME: attributes {dso_local}
+define dso_local void @dsolocal_func() {
+ ret void
+}
+
+; // -----
+
; CHECK-LABEL: @func_readnone
; CHECK-SAME: attributes {memory_effects = #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>}
; CHECK: llvm.return