Skip to content

Commit 6f27742

Browse files
committed
Add local unnamed address kinds
1 parent 7dc0f30 commit 6f27742

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

Sources/LLVM/IRGlobal.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ extension IRGlobal {
3434

3535
/// Retrieves an indicator for the significance of a global value's address.
3636
public var unnamedAddressKind: UnnamedAddressKind {
37-
get { return UnnamedAddressKind(llvm: LLVMHasUnnamedAddr(asLLVM())) }
38-
set { LLVMSetUnnamedAddr(asLLVM(), newValue.llvm) }
37+
get { return UnnamedAddressKind(llvm: LLVMGetUnnamedAddress(asLLVM())) }
38+
set { LLVMSetUnnamedAddress(asLLVM(), newValue.llvm) }
3939
}
4040

4141
/// Retrieves the COMDAT section for this global, if it exists.

Sources/LLVM/Linkage.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,28 +237,29 @@ public enum UnnamedAddressKind {
237237
/// current module but it may or may not be significant to another module;
238238
/// only the content of the value is known to be significant within the
239239
/// current module.
240-
// case local
240+
case local
241241

242242
/// Indicates that the address of this global value is not significant to the
243243
/// current module or any other module; only the content of the value
244244
/// is significant globally.
245245
case global
246246

247-
private static let unnamedAddressMapping: [UnnamedAddressKind: LLVMBool] = [
248-
.none: LLVMBool(0),
249-
// .local: LLVMBool(1),
250-
.global: LLVMBool(1),
251-
]
247+
private static let unnamedAddressMapping: [UnnamedAddressKind: LLVMUnnamedAddr] = [
248+
.none: LLVMNoUnnamedAddr,
249+
.local: LLVMLocalUnnamedAddr,
250+
.global: LLVMGlobalUnnamedAddr,
251+
]
252252

253-
internal init(llvm: LLVMBool) {
253+
internal init(llvm: LLVMUnnamedAddr) {
254254
switch llvm {
255-
case 0: self = .none
256-
case 1: self = .global
255+
case LLVMNoUnnamedAddr: self = .none
256+
case LLVMLocalUnnamedAddr: self = .local
257+
case LLVMGlobalUnnamedAddr: self = .global
257258
default: fatalError("unknown unnamed address kind \(llvm)")
258259
}
259260
}
260261

261-
internal var llvm: LLVMBool {
262+
internal var llvm: LLVMUnnamedAddr {
262263
return UnnamedAddressKind.unnamedAddressMapping[self]!
263264
}
264265
}

0 commit comments

Comments
 (0)