Classes
The following classes are available globally.
-
A
Comdat
object represents a particular COMDAT section in a final generated ELF or COFF object file. All COMDAT sections are keyed by a unique name that the linker uses, in conjunction with the section’sselectionKind
to determine how to treat conflicting or identical COMDAT sections at link time.COMDAT sections are typically used by languages where multiple translation units may define the same symbol, but where
One-Definition-Rule
(ODR)-like concepts apply (perhaps because taking the address of the object referenced by the symbol is defined behavior). For example, a C++ header file may define an inline function that cannot be successfully inlined at all call sites. The C++ compiler would then emit a COMDAT section in each object file for the function with the.any
selection kind and the linker would pick any section it desires before emitting the final object file.It is important to be aware of the selection kind of a COMDAT section as these provide strengths and weaknesses at compile-time and link-time. It is also important to be aware that only certain platforms support mixing identically-keyed COMDAT sections with mixed selection kinds e.g. COFF supports mixing
.any
and.largest
, WebAssembly only supports.any
, and Mach-O doesn’t support COMDAT sections at all.When targeting COFF, there are also restrictions on the way global objects must appear in COMDAT sections. All global objects and aliases to those global objects must belong to a COMDAT group with the same name and must have greater than local linkage. Else the local symbol may be renamed in the event of a collision, defeating code-size savings.
The combined use of COMDATS and sections may yield surprising results. For example:
let module = Module(name: "COMDATTest") let builder = IRBuilder(module: module) let foo = module.comdat(named: "foo") let bar = module.comdat(named: "bar") var g1 = builder.addGlobal("g1", initializer: IntType.int8.constant(42)) g1.comdat = foo var g2 = builder.addGlobal("g2", initializer: IntType.int8.constant(42)) g2.comdat = bar
From the object file perspective, this requires the creation of two sections with the same name. This is necessary because both globals belong to different COMDAT groups and COMDATs, at the object file level, are represented by sections.
See moreDeclaration
Swift
public class Comdat
-
An
See moreIRBuilder
is a helper object that generates LLVM instructions. IR Builders keep track of a position within a function or basic block and has methods to insert instructions at that position.Declaration
Swift
public class IRBuilder
-
A
JIT
is a Just-In-Time compiler that will compile and execute LLVM IR that has been generated in aModule
. It can execute arbitrary functions and return the value the function generated, allowing you to write interactive programs that will run as soon as they are compiled.The JIT is fundamentally lazy, and allows control over when and how symbols are resolved.
See moreDeclaration
Swift
public final class JIT
-
MemoryBuffer
provides simple read-only access to a block of memory, and provides simple methods for reading files and standard input into a memory buffer. In addition to basic access to the characters in the file, this interface guarantees you can read one character past the end of the file, and that this character will read as ‘\0’.The ‘\0’ guarantee is needed to support an optimization – it’s intended to be more efficient for clients which are reading all the data to stop reading when they encounter a ‘\0’ than to continually check the file position to see if it has reached the end of the file.
See moreDeclaration
Swift
public class MemoryBuffer : Sequence
-
A
See moreContext
represents execution states for the core LLVM IR system.Declaration
Swift
public class Context
-
A
See moreModule
represents the top-level structure of an LLVM program. An LLVM module is effectively a translation unit or a collection of translation units merged together.Declaration
Swift
public final class Module : CustomStringConvertible
-
A
See moreNamedMetadata
object represents a module-level metadata value identified by a user-provided name. Named metadata is generated lazily when operands are attached.Declaration
Swift
public class NamedMetadata
-
An in-memory representation of a format-independent object file.
See moreDeclaration
Swift
public class ObjectFile
-
A sequence for iterating over the sections in an object file.
See moreDeclaration
Swift
public class SectionSequence : Sequence
-
A sequence for iterating over the relocations in an object file.
See moreDeclaration
Swift
public class RelocationSequence : Sequence
-
A sequence for iterating over the symbols in an object file.
See moreDeclaration
Swift
public class SymbolSequence : Sequence
-
A
See moreFunctionPassManager
is an object that collects a sequence of passes which run over a particular IR construct, and runs each of them in sequence over each such construct.Declaration
Swift
public class FunctionPassManager
-
A
See moreTargetData
encapsulates information about the data requirements of a particular target architecture and can be used to retrieve information about sizes and offsets of types with respect to this target.Declaration
Swift
public class TargetData
-
A
See moreTarget
object represents an object that encapsulates information about a host architecture, vendor, ABI, etc.Declaration
Swift
public class Target
-
A
See moreTargetMachine
object represents an object that encapsulates information about a particular machine (i.e. CPU type) associated with a target environment.Declaration
Swift
public class TargetMachine