diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -256,10 +256,13 @@ rewriter.getArrayAttr(newArgAttrs))); } - // Create an LLVM function, use external linkage by default until MLIR - // functions have linkage. + // Create an LLVM function, use external/internal linkage as specified by + // public/private attribute until MLIR functions have linkage. + LLVM::Linkage linkage = (funcOp.isPublic() || funcOp.isExternal()) + ? LLVM::Linkage::External + : LLVM::Linkage::Private; auto newFuncOp = rewriter.create( - funcOp.getLoc(), funcOp.getName(), llvmType, LLVM::Linkage::External, + funcOp.getLoc(), funcOp.getName(), llvmType, linkage, /*dsoLocal*/ false, attributes); rewriter.inlineRegionBefore(funcOp.getBody(), newFuncOp.getBody(), newFuncOp.end());