Skip to content

Commit 4fc514a

Browse files
ghehggysit
andauthored
[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 <[email protected]>
1 parent 382d359 commit 4fc514a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

mlir/lib/Target/LLVMIR/ModuleImport.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,7 @@ LogicalResult ModuleImport::processFunction(llvm::Function *func) {
21392139
iface.isConvertibleIntrinsic(func->getIntrinsicID()))
21402140
return success();
21412141

2142-
bool dsoLocal = func->hasLocalLinkage();
2142+
bool dsoLocal = func->isDSOLocal();
21432143
CConv cconv = convertCConvFromLLVM(func->getCallingConv());
21442144

21452145
// Insert the function at the end of the module.

mlir/test/Target/LLVMIR/Import/function-attributes.ll

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ define internal spir_func void @spir_func_internal() {
1212

1313
; // -----
1414

15+
; Ensure that we have dso_local.
16+
; CHECK: llvm.func @dsolocal_func()
17+
; CHECK-SAME: attributes {dso_local}
18+
define dso_local void @dsolocal_func() {
19+
ret void
20+
}
21+
22+
; // -----
23+
1524
; CHECK-LABEL: @func_readnone
1625
; CHECK-SAME: attributes {memory_effects = #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>}
1726
; CHECK: llvm.return

0 commit comments

Comments
 (0)