IRMetadata
public protocol IRMetadata : _IRMetadataInitializerHack
The Metadata
protocol captures those types that represent metadata nodes
in LLVM IR.
LLVM IR allows metadata to be attached to instructions in the program that can convey extra information about the code to the optimizers and code generator. One example application of metadata is source-level debug information.
Metadata does not have a type, and is not a value. If referenced from a call instruction, it uses the metadata type.
Debug Information
The idea of LLVM debugging information is to capture how the important pieces of the source-language’s Abstract Syntax Tree map onto LLVM code. LLVM takes a number of positions on the impact of the broader compilation process on debug information:
- Debugging information should have very little impact on the rest of the compiler. No transformations, analyses, or code generators should need to be modified because of debugging information.
- LLVM optimizations should interact in well-defined and easily described ways with the debugging information.
- Because LLVM is designed to support arbitrary programming languages, LLVM-to-LLVM tools should not need to know anything about the semantics of the source-level-language.
- Source-level languages are often widely different from one another. LLVM should not put any restrictions of the flavor of the source-language, and the debugging information should work with any language.
- With code generator support, it should be possible to use an LLVM compiler to compile a program to native machine code and standard debugging formats. This allows compatibility with traditional machine-code level debuggers, like GDB, DBX, or CodeView.
-
Retrieves the underlying LLVM metadata object.
Declaration
Swift
func asMetadata() -> LLVMMetadataRef
-
replaceAllUses(with:
Extension method) Replaces all uses of the this metadata with the given metadata.
Declaration
Swift
public func replaceAllUses(with metadata: IRMetadata)
Parameters
metadata
The new value to swap in.
-
dump()
Extension methodDumps a representation of this metadata to stderr.
Declaration
Swift
public func dump()
-
forceCast(to:
Extension method) Force-casts metadata to a destination type.
Warning
In general, use of this method is discouraged and can lead to unpredictable results or undefined behavior. No checks are performed before, during, or after the cast.Declaration
Swift
public func forceCast<DestTy>(to: DestTy.Type) -> DestTy where DestTy : IRMetadata
-
kind
Extension methodReturns the kind of this metadata node.
Declaration
Swift
public var kind: IRMetadataKind { get }