[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:13:07 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-llvm

Author: Guojin (ghehg)

<details>
<summary>Changes</summary>

Function definitions mostly have external linkage thus would be missing dso_local attribute during translation.

---
Full diff: https://github.com/llvm/llvm-project/pull/124822.diff


2 Files Affected:

- (modified) mlir/lib/Target/LLVMIR/ModuleImport.cpp (+1-1) 
- (modified) mlir/test/Target/LLVMIR/Import/function-attributes-generic.ll (+10) 


``````````diff
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
+}

``````````

</details>


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


More information about the Mlir-commits mailing list