Linkage and standard dialect FuncOp

Presently, the LLVM linkage values are mirrored in the LLVM IR dialect. For example, mlir::LLVM::Linkage::Linkonce, mlir::LLVM::Linkage::Common, mlir::LLVM::Linkage::Weak, etc.

However, in StandardToLLVM.cpp, the converter for FuncOp always uses mlir::LLVM::Linkage::External.

Indeed, there is a comment there:

     // Create an LLVM function, use external linkage by default until MLIR
     // functions have linkage.

This begs the question. Are there any further plans to move linkage into MLIR’s FuncOp?

For FIR, we currently have a little workaround code stuck in here that looks for a StringAttr and selects the LLVM IR dialect value accordingly, but obviously there are many possible routes to a solution one might take here.

1 Like