diff --git a/Sources/CodeGen/LLVM/Transpilation.swift b/Sources/CodeGen/LLVM/Transpilation.swift index 4c15610ba..1309fc76d 100644 --- a/Sources/CodeGen/LLVM/Transpilation.swift +++ b/Sources/CodeGen/LLVM/Transpilation.swift @@ -443,6 +443,11 @@ extension LLVM.Module { // setLinkage(.private, for: llvmFunction) // } + // Monomorphized functions always have private linkage. + if f.isMonomorphized { + setLinkage(.private, for: llvmFunction) + } + // Functions that return `Never` have the `noreturn` attribute. if !m[f].isSubscript && (m[f].output == .never) { addAttribute(.init(.noreturn, in: &self), to: llvmFunction) diff --git a/Sources/IR/FunctionID.swift b/Sources/IR/FunctionID.swift index 06675d872..41e121451 100644 --- a/Sources/IR/FunctionID.swift +++ b/Sources/IR/FunctionID.swift @@ -61,6 +61,16 @@ extension Function { self.value = .monomorphized(base: base, arguments: arguments) } + /// `true` if `self` is the identity of a monomorphized function. + public var isMonomorphized: Bool { + switch value { + case .monomorphized: + return true + default: + return false + } + } + } }