Context
public class Context
A Context
is an LLVM compilation session environment.
A Context
is a container for the global state of an execution of the
LLVM environment and tooling. It contains independent copies of global and
module-level entities like types, metadata attachments, and constants.
An LLVM context is needed for interacting with LLVM in a concurrent environment. Because a context maintains state independent of any other context, it is recommended that each thread of execution be assigned a unique context. LLVM’s core infrastructure and API provides no locking guarantees and no atomicity guarantees.
-
Retrieves the global context instance.
The global context is an particularly convenient instance managed by LLVM itself. It is the default context provided for any operations that require it.
Warning
Failure to specify the correct context in concurrent environments can lead to data corruption. In general, it is always recommended that each thread of execution attempting to access the LLVM API have its ownContext
instance, rather than rely on this global context.Declaration
Swift
public static let global: Context
-
Creates a new
Context
object.Declaration
Swift
public init()
-
Creates a
Context
object from anLLVMContextRef
object.Declaration
Swift
public init(llvm: LLVMContextRef, ownsContext: Bool = false)
-
Returns whether the given context is set to discard all value names.
If true, only the names of GlobalValue objects will be available in the IR. This can be used to save memory and processing time, especially in release environments.
Declaration
Swift
public var discardValueNames: Bool { get set }
-
Searches for and retrieves a metadata kind with the given name in this context. If none is found, one with that name is created and its unique identifier is returned.
Declaration
Swift
public func metadataKind(named name: String, in context: Context = .global) -> UInt32