Skip to content

Commit

Permalink
Merge pull request #963 from hylo-lang/dup-monomorphized-symbols
Browse files Browse the repository at this point in the history
Ensure monomorphized symbols have private linkage
  • Loading branch information
kyouko-taiga authored Sep 6, 2023
2 parents 7e61568 + e75782f commit 4d79840
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 4d79840

Please sign in to comment.