File tree 5 files changed +265
-166
lines changed
5 files changed +265
-166
lines changed Original file line number Diff line number Diff line change @@ -31,4 +31,18 @@ extension IRGlobal {
31
31
get { return StorageClass ( llvm: LLVMGetDLLStorageClass ( asLLVM ( ) ) ) }
32
32
set { LLVMSetDLLStorageClass ( asLLVM ( ) , newValue. llvm) }
33
33
}
34
+
35
+ /// Retrieves the section associated with the symbol that will eventually be
36
+ /// emitted for this global value.
37
+ ///
38
+ /// - Note: Global `Alias` values may or may not be resolvable to any
39
+ /// particular section given the state of the IR in an arbitrary module. A
40
+ /// return value of the empty string indicates a failed section lookup.
41
+ public var section : String {
42
+ get {
43
+ guard let sname = LLVMGetSection ( asLLVM ( ) ) else { return " " }
44
+ return String ( cString: sname)
45
+ }
46
+ set { LLVMSetSection ( asLLVM ( ) , newValue) }
47
+ }
34
48
}
Original file line number Diff line number Diff line change @@ -148,6 +148,21 @@ public final class Module: CustomStringConvertible {
148
148
}
149
149
}
150
150
151
+ /// Links the given module with this module. If the link succeeds, this
152
+ /// module will the composite of the two input modules.
153
+ ///
154
+ /// The result of this function is `true` if the link succeeds, or `false`
155
+ /// otherwise - unlike `llvm::Linker::linkModules`.
156
+ ///
157
+ /// - parameter other: The module to link with this module.
158
+ public func link( _ other: Module ) -> Bool {
159
+ // First clone the other module; `LLVMLinkModules2` consumes the source
160
+ // module via a move and that module still owns its ModuleRef.
161
+ let otherClone = LLVMCloneModule ( other. llvm)
162
+ // N.B. Returns `true` on error.
163
+ return LLVMLinkModules2 ( self . llvm, otherClone) == 0
164
+ }
165
+
151
166
/// Retrieves the sequence of functions that make up this module.
152
167
public var functions : AnySequence < Function > {
153
168
var current = firstFunction
You can’t perform that action at this time.
0 commit comments