Skip to content

Commit

Permalink
Ensure monomorphized symbols have private linkage
Browse files Browse the repository at this point in the history
  • Loading branch information
kyouko-taiga committed Sep 6, 2023
1 parent dd32841 commit e75782f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/CodeGen/LLVM/Transpilation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions Sources/IR/FunctionID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

}

}
Expand Down

0 comments on commit e75782f

Please sign in to comment.