Metadata
LLVM.Metadata — Type
MetadataAbstract supertype for all metadata types.
LLVM.MDString — Type
MDStringA string metadata node.
LLVM.MDString — Method
MDString(val::AbstractString)Create a new string metadata node from the given Julia string.
Core.String — Method
String(md::MDString)Get the string value of the given string metadata node.
LLVM.MDNode — Type
MDNodeAbstract supertype for metadata nodes that can have operands.
See also: MDTuple for a concrete subtype.
Properties
md.operandsThe operands of the metadata node, as a view of the node that supports indexing and iteration. Null operands are represented by nothing.
The view is mutable: assigning an operand, md.operands[i] = new, replaces it in place. LLVM keeps uniqued nodes (i.e., nodes that are neither distinct nor temporary) unique, so if the change makes the node identical to an existing one, the node is made distinct instead. Nodes that refer to temporary nodes are replaced by that existing node and deleted.
LLVM.MDTuple — Type
MDTupleA tuple metadata node.
LLVM.MDTuple — Method
MDTuple(elements::AbstractVector) -> MDTupleCreate a new tuple metadata node with the given elements as its operands, or get the existing one, in the task-local context.
Passing nothing as an element will result in a null operand.
LLVM.MDNode — Method
MDNode(elements::AbstractVector) -> MDTupleCreate a new tuple metadata node. Equivalent to MDTuple(elements).
LLVM.MDNode — Method
MDNode(r::ConstantRange) -> MDTupleCreate !range metadata for the range r, in the task-local context. The range must not be empty or full, which !range metadata can't represent. Attach it to an instruction using inst.metadata[LLVM.MD_range] = MDNode(r).
Temporary nodes
LLVM.TemporaryMDNode — Type
TemporaryMDNode{T<:MDNode}A temporary metadata node: a placeholder that other metadata can refer to before the node it stands for can be created, e.g., to create metadata that refers to itself.
The handle owns the temporary node, which needs to be replaced with replace_temporary!, or disposed of with dispose, which replaces its uses with null operands. Either one consumes the handle, after which disposing of it again does nothing, so the handle can be disposed of with @dispose or the do-block form of the constructor even if it was replaced.
Properties
temp.nodeThe temporary node, a T, for use as an operand of other metadata. Throws an ArgumentError once the handle has been consumed, which also invalidates the nodes that were obtained from it before.
LLVM.TemporaryMDNode — Method
TemporaryMDNode(operands=Metadata[]) -> TemporaryMDNode{MDTuple}
TemporaryMDNode(f::Function, operands=Metadata[])Create a temporary tuple node with the given operands, in the task-local context. Passing nothing as an operand results in a null operand.
The do-block form calls f with the handle and disposes of it afterwards, unless f replaced it, and returns the result of f:
node = TemporaryMDNode() do temp
replace_temporary!(temp, MDNode([temp.node, MDString("loop")]))
endLLVM.replace_temporary! — Function
replace_temporary!(temp::TemporaryMDNode, replacement::Metadata) -> replacementReplace every use of the temporary node temp with replacement, and delete the temporary node, consuming the handle.
A uniqued node that used temp can become identical to an existing node, in which case LLVM replaces it by that node and deletes it, invalidating it.
LLVM.dispose — Method
dispose(temp::TemporaryMDNode)Delete the temporary node temp, replacing its uses with null operands, unless the handle has already been consumed.
Metadata <-> Value
LLVM.ValueAsMetadata — Type
LLVM.ValueAsMetadataAbstract type for values wrapped as metadata, for use in APIs that expect a LLVM.Metadata.
See also: Metadata(::Value) to convert back to a metadata.
LLVM.Metadata — Method
Metadata(val::Value)Wrap the given value as metadata, for use in APIs that expect a LLVM.Metadata.
When the value is already metadata wrapped as a value, this will simply return the original metadata.
LLVM.MetadataAsValue — Type
LLVM.MetadataAsValueMetadata wrapped as a regular value, for use in APIs that expect a LLVM.Value.
See also: Value(::Metadata) to convert back to a value.
LLVM.Value — Method
Value(md::Metadata)Wrap the given metadata as a value, for use in APIs that expect a LLVM.Value.
When the metadata is already a value wrapped as metadata, this will simply return the original value.
Inspecting and attaching
LLVM.NamedMDNode — Type
NamedMDNodeA named metadata node, which is a collection of metadata nodes with a name.
Properties
node.nameThe name of the named metadata node.
node.operandsThe operands of the named metadata node, as a view of the node that supports indexing and iteration. The view is mutable, and supports:
push!(node.operands, md::MDNode): append an operand;node.operands[i] = md::MDNode: replace an operand;empty!(node.operands): remove all operands.node.next node.prev
The next or previous named metadata node in the module, or nothing if there is none.
LLVM.MDKind — Type
MDKind
MDKind(name::AbstractString; context=context())The kinds of metadata, which index the metadata of instructions and global objects. The kinds that LLVM knows about have a fixed value, like MD_dbg (for !dbg), MD_tbaa or MD_invariant_load, while the kinds of other names are specific to a context, and can be looked up by name (in the active context by default).
Instead of a kind, the metadata of instructions and global objects can also be indexed by the name of the kind, like inst.metadata["tbaa"], which is looked up in the context of the instruction or global object.
LLVM.add_metadata! — Function
add_metadata!(obj::LLVM.GlobalObject, kind, node::MDNode)Attach metadata to a global object, keeping the attachments of the same kind that it already has (unlike assigning to obj.metadata[kind], which replaces them). Global objects can have several attachments of one kind, e.g., a global variable that is described by several !dbg expressions. The kind can be an MDKind or the name of the kind. Returns obj.
LLVM.drop_unknown_metadata! — Function
drop_unknown_metadata!(inst::Instruction, known=())Drop the metadata of an instruction, except for its debug location and other debug metadata, and the metadata of the known kinds (metadata kinds or their names), using LLVM's Instruction::dropUnknownNonDebugMetadata. Passes do this when they move an instruction to where metadata that depends on the instruction's original position (e.g., !range or !nonnull on a load that a condition guarded) may not hold anymore.
LLVM.copy_metadata! — Function
copy_metadata!(dest::Instruction, src::Instruction, kinds=())Copy the metadata of src, including its debug location, to dest, e.g., when replacing an instruction by a new one. If kinds (metadata kinds or their names) are given, only the metadata of those kinds is copied, and the debug location only if they include MD_dbg. Metadata of dest is overwritten by that of src, but kept for kinds that src doesn't have.
This uses LLVM's Instruction::copyMetadata, so it follows that function's handling of the debug location: if src has none, LLVM 21 and later keep the debug location of dest, while earlier versions remove it, unless src has no metadata at all.
LLVM.MD_dbg — Constant
MD_dbgThe kind of !dbg metadata, which has a fixed value. See MDKind.
LLVM.MD_tbaa — Constant
MD_tbaaThe kind of !tbaa metadata, which has a fixed value. See MDKind.
LLVM.MD_prof — Constant
MD_profThe kind of !prof metadata, which has a fixed value. See MDKind.
LLVM.MD_fpmath — Constant
MD_fpmathThe kind of !fpmath metadata, which has a fixed value. See MDKind.
LLVM.MD_range — Constant
MD_rangeThe kind of !range metadata, which has a fixed value. See MDKind.
LLVM.MD_tbaa_struct — Constant
MD_tbaa_structThe kind of !tbaa.struct metadata, which has a fixed value. See MDKind.
LLVM.MD_invariant_load — Constant
MD_invariant_loadThe kind of !invariant.load metadata, which has a fixed value. See MDKind.
LLVM.MD_alias_scope — Constant
MD_alias_scopeThe kind of !alias.scope metadata, which has a fixed value. See MDKind.
LLVM.MD_noalias — Constant
MD_noaliasThe kind of !noalias metadata, which has a fixed value. See MDKind.
LLVM.MD_nontemporal — Constant
MD_nontemporalThe kind of !nontemporal metadata, which has a fixed value. See MDKind.
LLVM.MD_mem_parallel_loop_access — Constant
MD_mem_parallel_loop_accessThe kind of !llvm.mem.parallel_loop_access metadata, which has a fixed value. See MDKind.
LLVM.MD_nonnull — Constant
MD_nonnullThe kind of !nonnull metadata, which has a fixed value. See MDKind.
LLVM.MD_dereferenceable — Constant
MD_dereferenceableThe kind of !dereferenceable metadata, which has a fixed value. See MDKind.
LLVM.MD_dereferenceable_or_null — Constant
MD_dereferenceable_or_nullThe kind of !dereferenceable_or_null metadata, which has a fixed value. See MDKind.
LLVM.MD_make_implicit — Constant
MD_make_implicitThe kind of !make.implicit metadata, which has a fixed value. See MDKind.
LLVM.MD_unpredictable — Constant
MD_unpredictableThe kind of !unpredictable metadata, which has a fixed value. See MDKind.
LLVM.MD_invariant_group — Constant
MD_invariant_groupThe kind of !invariant.group metadata, which has a fixed value. See MDKind.
LLVM.MD_align — Constant
MD_alignThe kind of !align metadata, which has a fixed value. See MDKind.
LLVM.MD_loop — Constant
MD_loopThe kind of !llvm.loop metadata, which has a fixed value. See MDKind.
LLVM.MD_type — Constant
MD_typeThe kind of !type metadata, which has a fixed value. See MDKind.
LLVM.MD_section_prefix — Constant
MD_section_prefixThe kind of !section_prefix metadata, which has a fixed value. See MDKind.
LLVM.MD_absolute_symbol — Constant
MD_absolute_symbolThe kind of !absolute_symbol metadata, which has a fixed value. See MDKind.
LLVM.MD_associated — Constant
MD_associatedThe kind of !associated metadata, which has a fixed value. See MDKind.
LLVM.MD_noundef — Constant
MD_noundefThe kind of !noundef metadata, which has a fixed value. See MDKind.
Debug information
LLVM.DINode — Type
DINodea tagged DWARF-like metadata node.
Properties
node.tagThe DWARF tag of the node, or 0 if it has none. Requires LLVM 17+.
The properties of MDNode are available too.
Builder
LLVM.DIBuilder — Type
DIBuilderA builder for constructing debug information metadata.
This object needs to be disposed of using dispose, which also finalizes the debug info. Call finalize! explicitly only if you need to use the finalized debug info (e.g. emit code) before disposing of the builder.
The scope of declarations (types, subprograms, global variables, namespaces, modules and imported entities) can be nothing, for a declaration at the top level. Local variables, labels, lexical blocks and locations require a DILocalScope.
LLVM.DIBuilder — Method
DIBuilder(mod::Module; allow_unresolved::Bool=true)Create a new debug info builder that emits metadata into mod.
When allow_unresolved is true (the default), the builder collects unresolved metadata nodes attached to the module so that cycles can be resolved during dispose. When false, the builder errors on unresolved nodes instead.
LLVM.dispose — Method
dispose(builder::DIBuilder)Finalize the debug info and dispose of the builder. Finalization populates the compile unit's enum/retained-type/global/imported-entity/macro arrays, seals each subprogram's retained-nodes list, and resolves remaining cycles. If no compile unit was registered with the builder, or the debug info was already finalized through finalize!, finalization is skipped: DIBuilder::finalize is not idempotent (e.g., re-finalizing accesses already-deleted temporary macro files).
LLVM.finalize! — Method
finalize!(builder::DIBuilder)Resolve any unresolved metadata nodes and mark all compile units finalized. Called automatically by dispose; call explicitly only if the DI-enriched module must be consumed (e.g. for code emission) before the builder is disposed of. Skipped if no compile unit has been registered, or if the debug info has already been finalized.
LLVM.finalize_subprogram! — Function
finalize_subprogram!(builder::DIBuilder, sp::DISubprogram)Materialize the retained nodes currently tracked for sp. Call this after adding its local variables if finalizing it early. dispose and finalize! finalize tracked subprograms automatically.
Location information
LLVM.DILocation — Type
DILocationA location in the source code.
Properties
loc.lineThe line number of the debug location, or -1 if unknown.
loc.columnThe column number of the debug location.
loc.scopeThe local scope of the debug location, a DILocalScope.
loc.inlined_atThe location that the code at this debug location has been inlined at, or nothing if it hasn't been inlined.
The properties of MDNode are available too.
Variables
LLVM.DIVariable — Type
DIVariableAbstract supertype for all variable-like metadata nodes.
Properties
var.fileThe file in which the variable is declared, or nothing if unknown.
var.scopeThe scope of the variable, or nothing if unknown. The scope of a local variable is a DILocalScope.
var.lineThe line number at which the variable is declared, or -1 if unknown.
LLVM.DILocalVariable — Type
DILocalVariable <: DIVariableA local variable in the source code.
LLVM.DIGlobalVariable — Type
DIGlobalVariable <: DIVariableA global variable in the source code.
Scopes
LLVM.DIScope — Type
DIScopeAbstract supertype for lexical scopes and types (which are also declaration contexts).
Properties
scope.fileThe file associated with the scope, or nothing if it has none.
scope.nameThe name of the scope, or nothing if it has none.
LLVM.DILocalScope — Type
DILocalScopeAbstract supertype for scopes that can contain local variables, labels and source locations: subprograms (DISubprogram) and the lexical blocks nested in them (LLVM.DILexicalBlock and LLVM.DILexicalBlockFile).
File
LLVM.DIFile — Type
DIFileA file in the source code.
Properties
file.directoryThe directory of the file.
file.filenameThe name of the file.
file.sourceThe source code of the file, or nothing if it is not available.
The properties of DIScope, DINode and MDNode are available too.
LLVM.file! — Function
file!(builder::DIBuilder, filename::AbstractString, directory::AbstractString) -> DIFileCreate a new DIFile describing the given source file.
Lexical Block
LLVM.DILexicalBlock — Type
DILexicalBlockA lexical block (a nested scope, typically a compound statement) in the source code.
LLVM.DILexicalBlockFile — Type
DILexicalBlockFileA lexical block that changes the current source file, e.g. due to an #include.
LLVM.lexical_block! — Function
lexical_block!(builder::DIBuilder, scope::DILocalScope, file::DIFile,
line::Integer, column::Integer) -> DILexicalBlockCreate a new DILexicalBlock describing a nested source scope.
LLVM.lexical_block_file! — Function
lexical_block_file!(builder::DIBuilder, scope::DILocalScope, file::DIFile;
discriminator::Integer=0) -> DILexicalBlockFileCreate a new DILexicalBlockFile for tracking source-file changes within a lexical scope.
Module
LLVM.DIModule — Type
DIModuleA module in the source code (Clang modules / Fortran modules / Swift modules).
LLVM.dimodule! — Function
dimodule!(builder::DIBuilder, parent_scope::Union{DIScope,Nothing}, name::AbstractString;
config_macros::AbstractString="", include_path::AbstractString="",
api_notes_file::AbstractString="") -> DIModuleCreate a new DIModule describing a module in the source code.
Namespace
LLVM.DINamespace — Type
DINamespaceA namespace in the source code.
LLVM.namespace! — Function
namespace!(builder::DIBuilder, parent_scope::Union{DIScope,Nothing}, name::AbstractString;
export_symbols::Bool=false) -> DINamespaceCreate a new DINamespace describing a namespace in the source code.
Type
LLVM.DIType — Type
DITypeAbstract supertype for all type-like metadata nodes.
Properties
typ.nameThe name of the type, or nothing if it has none.
typ.size_in_bitsThe size in bits of the type.
typ.offset_in_bitsThe offset in bits of the type, e.g., of a member within its structure.
typ.lineThe line number at which the type is declared, or -1 if unknown.
typ.flagsThe flags of the type, as an LLVM.API.LLVMDIFlags bitmask.
typ.align_in_bitsThe alignment in bits of the type, or 0 if it has none.
The properties of DIScope, DINode and MDNode are available too.
LLVM.DIBasicType — Type
DIBasicType <: DITypeA primitive type (integer, floating-point, boolean, ...), built with basic_type!.
LLVM.DIDerivedType — Type
DIDerivedType <: DITypeA type derived from another type by adding qualifiers, reference/pointer indirection, a typedef name, or by describing a member/field. Built with pointer_type!, typedef_type!, member_type!, and the other qualifier/member factories.
LLVM.DICompositeType — Type
DICompositeType <: DITypeAn aggregate type (struct, union, class, array, vector, enumeration, ...). Built with struct_type!, union_type!, array_type!, etc.
LLVM.DISubroutineType — Type
DISubroutineType <: DITypeA function/subroutine type, listing the return and parameter types. Built with subroutine_type!.
LLVM.DIEnumerator — Type
DIEnumeratorA single enumerator value in an enumeration type.
LLVM.DISubrange — Type
DISubrangeA subrange describing one dimension of an array or vector type.
LLVM.DISubrangeType — Type
DISubrangeType <: DITypeA subrange type (an integer range type, as found in Fortran or Ada), built with subrange_type!. Requires LLVM 21+.
Properties
Built-in factories for primitive types:
LLVM.basic_type! — Function
basic_type!(builder::DIBuilder, name::AbstractString, size_in_bits::Integer,
encoding::Integer; flags=API.LLVMDIFlagZero) -> DIBasicTypeCreate a new DIBasicType, such as an integer or floating-point type. encoding is a DW_ATE_* value (see the DWARF standard).
LLVM.unspecified_type! — Function
unspecified_type!(builder::DIBuilder, name::AbstractString) -> DIBasicTypeCreate a new unspecified type (DW_TAG_unspecified_type), e.g. a C++ decltype(nullptr).
LLVM.nullptr_type! — Function
nullptr_type!(builder::DIBuilder) -> DIBasicTypeCreate a new type representing a null pointer.
Derived types (pointers, qualifiers, members, inheritance, ...):
LLVM.pointer_type! — Function
pointer_type!(builder::DIBuilder, pointee_type::DIType, size_in_bits::Integer;
align_in_bits::Integer=0, address_space::Integer=0,
name::AbstractString="") -> DIDerivedTypeCreate a new pointer type.
LLVM.reference_type! — Function
reference_type!(builder::DIBuilder, tag::Integer, type::DIType) -> DIDerivedTypeCreate a new reference type (C++ T& / T&&), with the given DWARF tag (e.g. DW_TAG_reference_type or DW_TAG_rvalue_reference_type).
LLVM.lvalue_reference_type! — Function
lvalue_reference_type!(builder::DIBuilder, type::DIType) -> DIDerivedTypeCreate a C++ T& reference type. Shorthand for reference_type!(builder, DW_TAG_reference_type, type).
LLVM.rvalue_reference_type! — Function
rvalue_reference_type!(builder::DIBuilder, type::DIType) -> DIDerivedTypeCreate a C++ T&& rvalue-reference type. Shorthand for reference_type!(builder, DW_TAG_rvalue_reference_type, type).
LLVM.typedef_type! — Function
typedef_type!(builder::DIBuilder, type::DIType, name::AbstractString,
file::DIFile, line::Integer, scope::Union{DIScope,Nothing};
align_in_bits::Integer=0) -> DIDerivedTypeCreate a new typedef type.
LLVM.qualified_type! — Function
qualified_type!(builder::DIBuilder, tag::Integer, type::DIType) -> DIDerivedTypeCreate a new qualified type, such as const T (DW_TAG_const_type) or volatile T (DW_TAG_volatile_type). See also the named convenience wrappers const_type! and volatile_type!.
LLVM.const_type! — Function
const_type!(builder::DIBuilder, type::DIType) -> DIDerivedTypeCreate a const-qualified type. Shorthand for qualified_type!(builder, DW_TAG_const_type, type).
LLVM.volatile_type! — Function
volatile_type!(builder::DIBuilder, type::DIType) -> DIDerivedTypeCreate a volatile-qualified type. Shorthand for qualified_type!(builder, DW_TAG_volatile_type, type).
LLVM.artificial_type! — Function
artificial_type!(builder::DIBuilder, type::DIType) -> DITypeCreate a new artificial type (DI_FLAG_ARTIFICIAL), e.g. an implicit this. The concrete subtype matches the input (e.g. a DIBasicType stays a DIBasicType).
LLVM.object_pointer_type! — Function
object_pointer_type!(builder::DIBuilder, type::DIType;
implicit::Bool=true) -> DITypeCreate a new type identifying an object pointer (DI_FLAG_OBJECT_POINTER). The concrete subtype matches the input. When implicit is true (the default, and the only behavior before LLVM 20) the clone also sets DI_FLAG_ARTIFICIAL.
LLVM.member_type! — Function
member_type!(builder::DIBuilder, scope::Union{DIScope,Nothing}, name::AbstractString,
file::DIFile, line::Integer, size_in_bits::Integer,
align_in_bits::Integer, offset_in_bits::Integer,
type::DIType; flags=API.LLVMDIFlagZero) -> DIDerivedTypeCreate a new member (field) of a composite type.
LLVM.bitfield_member_type! — Function
bitfield_member_type!(builder::DIBuilder, scope::Union{DIScope,Nothing}, name::AbstractString,
file::DIFile, line::Integer, size_in_bits::Integer,
offset_in_bits::Integer, storage_offset_in_bits::Integer,
type::DIType; flags=API.LLVMDIFlagZero) -> DIDerivedTypeCreate a new bit-field member of a composite type.
LLVM.static_member_type! — Function
static_member_type!(builder::DIBuilder, scope::Union{DIScope,Nothing}, name::AbstractString,
file::DIFile, line::Integer, type::DIType,
constant_val::Constant;
flags=API.LLVMDIFlagZero,
align_in_bits::Integer=0) -> DIDerivedTypeCreate a new static member of a composite type. constant_val is required: the underlying C entry point unconditionally cast<Constant>s it and crashes on null.
LLVM.member_pointer_type! — Function
member_pointer_type!(builder::DIBuilder, pointee_type::DIType, class_type::DIType,
size_in_bits::Integer;
align_in_bits::Integer=0,
flags=API.LLVMDIFlagZero) -> DIDerivedTypeCreate a new pointer-to-member type for C++.
LLVM.inheritance! — Function
inheritance!(builder::DIBuilder, derived::DIType, base::DIType, base_offset::Integer;
vbptr_offset::Integer=0, flags=API.LLVMDIFlagZero) -> DIDerivedTypeCreate a new inheritance relationship from derived to base.
Composite types:
LLVM.struct_type! — Function
struct_type!(builder::DIBuilder, scope::Union{DIScope,Nothing}, name::AbstractString,
file::DIFile, line::Integer, size_in_bits::Integer,
align_in_bits::Integer, elements::AbstractVector;
flags=API.LLVMDIFlagZero, derived_from=nothing,
runtime_lang::Integer=0, vtable_holder=nothing,
unique_id::AbstractString="") -> DICompositeTypeCreate a new struct type.
LLVM.union_type! — Function
union_type!(builder::DIBuilder, scope::Union{DIScope,Nothing}, name::AbstractString,
file::DIFile, line::Integer, size_in_bits::Integer,
align_in_bits::Integer, elements::AbstractVector;
flags=API.LLVMDIFlagZero, runtime_lang::Integer=0,
unique_id::AbstractString="") -> DICompositeTypeCreate a new union type.
LLVM.class_type! — Function
class_type!(builder::DIBuilder, scope::Union{DIScope,Nothing}, name::AbstractString,
file::DIFile, line::Integer, size_in_bits::Integer,
align_in_bits::Integer, offset_in_bits::Integer,
elements::AbstractVector;
flags=API.LLVMDIFlagZero, derived_from=nothing,
vtable_holder=nothing, template_params=nothing,
unique_id::AbstractString="") -> DICompositeTypeCreate a new C++ class type.
LLVM.array_type! — Function
array_type!(builder::DIBuilder, size_in_bits::Integer, align_in_bits::Integer,
element_type::DIType, subscripts::AbstractVector) -> DICompositeTypeCreate a new array type. Subscripts are typically built with subrange!.
LLVM.vector_type! — Function
vector_type!(builder::DIBuilder, size_in_bits::Integer, align_in_bits::Integer,
element_type::DIType, subscripts::AbstractVector) -> DICompositeTypeCreate a new vector type. Subscripts are typically built with subrange!.
LLVM.enumerator! — Function
enumerator!(builder::DIBuilder, name::AbstractString, value::Integer;
unsigned::Bool=false, size_in_bits::Integer=64) -> DIEnumeratorCreate a new enumerator for use inside an enumeration type. The value is interpreted as a signed or unsigned integer of size_in_bits bits, and must fit in it. Sizes other than 64 bits require LLVM 21+.
LLVM.enumeration_type! — Function
enumeration_type!(builder::DIBuilder, scope::Union{DIScope,Nothing}, name::AbstractString,
file::DIFile, line::Integer, size_in_bits::Integer,
align_in_bits::Integer, elements::AbstractVector;
underlying_type=nothing) -> DICompositeTypeCreate a new enumeration type. elements should be a vector of DIEnumerator metadata nodes, and underlying_type is the integer type of the enumeration, if it has one.
LLVM.forward_decl! — Function
forward_decl!(builder::DIBuilder, tag::Integer, name::AbstractString,
scope::Union{DIScope,Nothing}, file::DIFile, line::Integer;
runtime_lang::Integer=0, size_in_bits::Integer=0,
align_in_bits::Integer=0,
unique_id::AbstractString="") -> DICompositeTypeCreate a new forward declaration to a composite type.
LLVM.replaceable_composite_type! — Function
replaceable_composite_type!(builder::DIBuilder, tag::Integer,
name::AbstractString, scope::Union{DIScope,Nothing},
file::DIFile, line::Integer;
runtime_lang::Integer=0, size_in_bits::Integer=0,
align_in_bits::Integer=0,
flags=API.LLVMDIFlagZero,
unique_id::AbstractString="")
-> TemporaryMDNode{DICompositeType}Create a temporary composite type, a placeholder for a type that refers to itself, e.g., through a pointer to it. Build the complete type with the temporary type as a placeholder, and then replace it with replace_temporary!, before the builder is finalized:
fwd = replaceable_composite_type!(dib, DW_TAG_structure_type, "Node", nothing, file, 1)
next = member_type!(dib, nothing, "next", file, 2, 64, 64, 0, pointer_type!(dib, fwd.node, 64))
node = struct_type!(dib, nothing, "Node", file, 1, 64, 64, [next])
replace_temporary!(fwd, node)LLVM.replace_arrays! — Function
replace_arrays!(builder::DIBuilder, T::DICompositeType,
elements::AbstractVector) -> DICompositeTypeReplace the elements array of the given composite type T, and return the resulting type. Use the returned type instead of T, as LLVM can replace T with an existing, identical type. Requires LLVM 21+.
LLVM.subrange! — Function
subrange!(builder::DIBuilder, lower_bound::Integer, count::Integer) -> DISubrangeGet or create a subrange, describing one dimension of an array or vector type.
LLVM.subrange_type! — Function
subrange_type!(builder::DIBuilder, scope::Union{DIScope,Nothing}, name::AbstractString,
file::DIFile, line::Integer, size_in_bits::Integer,
align_in_bits::Integer, base_type::DIType;
flags=API.LLVMDIFlagZero,
lower_bound=nothing, upper_bound=nothing,
stride=nothing, bias=nothing) -> DISubrangeTypeCreate a new subrange type. Requires LLVM 21+.
LLVM.set_type! — Function
set_type!(builder::DIBuilder, scope::Union{DIScope,Nothing}, name::AbstractString,
file::DIFile, line::Integer, size_in_bits::Integer,
align_in_bits::Integer, base_type::DIType) -> DIDerivedTypeCreate a new set type (DW_TAG_set_type). Requires LLVM 21+.
LLVM.dynamic_array_type! — Function
dynamic_array_type!(builder::DIBuilder, scope::Union{DIScope,Nothing}, name::AbstractString,
file::DIFile, line::Integer, size_in_bits::Integer,
align_in_bits::Integer, element_type::DIType,
subscripts::AbstractVector;
data_location=nothing, associated=nothing,
allocated=nothing, rank=nothing,
bit_stride=nothing) -> DICompositeTypeCreate a new dynamic array type (Fortran assumed-shape/deferred-shape arrays). Requires LLVM 21+.
Subroutine types:
LLVM.subroutine_type! — Function
subroutine_type!(builder::DIBuilder, file::DIFile,
return_type::Union{DIType,Nothing},
parameter_types::AbstractVector=Metadata[];
flags=API.LLVMDIFlagZero) -> DISubroutineTypeCreate a new subroutine type with the given return and parameter types. Pass nothing for return_type to describe a void-returning subroutine, and as the last parameter type of a variadic subroutine. The parameter types must be DITypes or nothing.
Objective-C:
LLVM.DIObjCProperty — Type
DIObjCPropertyAn Objective-C @property descriptor.
LLVM.objc_ivar! — Function
objc_ivar!(builder::DIBuilder, name::AbstractString, file::DIFile,
line::Integer, size_in_bits::Integer, align_in_bits::Integer,
offset_in_bits::Integer, type::DIType, property_node::Metadata;
flags=API.LLVMDIFlagZero) -> DIDerivedTypeCreate a new Objective-C instance variable.
LLVM.objc_property! — Function
objc_property!(builder::DIBuilder, name::AbstractString, file::DIFile,
line::Integer, getter::AbstractString, setter::AbstractString,
attributes::Integer, type::DIType) -> DIObjCPropertyCreate a new Objective-C @property descriptor.
Subprogram
LLVM.DISubprogram — Type
DISubprogram <: DILocalScopeA subprogram (a function) in the source code.
Properties
sp.lineThe line number of the subprogram, or -1 if unknown.
sp.linkage_nameThe linkage name of the subprogram, i.e., the (mangled) name of the function it describes, or nothing if it has none. Unlike the name of the function, this keeps the name that the function had when the debug info was created, e.g., when the function is renamed later.
The properties of DIScope, DINode and MDNode are available too.
LLVM.subprogram! — Function
subprogram!(builder::DIBuilder, scope::Union{DIScope,Nothing}, name::AbstractString,
file::DIFile, line::Integer, type::DISubroutineType;
linkage_name::AbstractString="", scope_line::Integer=line,
local_to_unit::Bool=false, definition::Bool=true,
flags=API.LLVMDIFlagZero, optimized::Bool=false) -> DISubprogramCreate a new DISubprogram describing a function. When linkage_name is empty, LLVM falls back to name. scope_line defaults to the function's line, which is the usual case.
LLVM.replace_type! — Function
replace_type!(sp::DISubprogram, ty::DISubroutineType)Replace the type of the given subprogram. Requires LLVM 21+.
Variables
Factories for local variables and parameters:
LLVM.auto_variable! — Function
auto_variable!(builder::DIBuilder, scope::DILocalScope, name::AbstractString,
file::DIFile, line::Integer, type::DIType;
always_preserve::Bool=false, flags=API.LLVMDIFlagZero,
align_in_bits::Integer=0) -> DILocalVariableCreate a new local variable descriptor (for a compiler-introduced automatic variable).
LLVM.parameter_variable! — Function
parameter_variable!(builder::DIBuilder, scope::DILocalScope, name::AbstractString,
arg_no::Integer, file::DIFile, line::Integer, type::DIType;
always_preserve::Bool=false,
flags=API.LLVMDIFlagZero) -> DILocalVariableCreate a new descriptor for a function parameter variable. arg_no is the 1-based parameter index.
Expressions
LLVM.DIExpression — Type
DIExpressionA DWARF expression that modifies how a variable's value is expressed at runtime.
LLVM.DIGlobalVariableExpression — Type
DIGlobalVariableExpressionA pairing of a DIGlobalVariable and its associated DIExpression.
Properties
gve.variableThe global variable described by the global variable expression.
gve.expressionThe expression of the global variable expression, which describes the location of the variable.
The properties of MDNode are available too.
LLVM.expression! — Function
expression!(builder::DIBuilder,
addr::AbstractVector{<:Integer}=UInt64[]) -> DIExpressionCreate a new DIExpression from the given array of opcodes (encoding a DWARF expression such as DW_OP_plus_uconst).
LLVM.constant_value_expression! — Function
constant_value_expression!(builder::DIBuilder, value::Integer) -> DIExpressionCreate a new DIExpression representing a single constant value.
LLVM.global_variable_expression! — Function
global_variable_expression!(builder::DIBuilder, scope::Union{DIScope,Nothing},
name::AbstractString, linkage::AbstractString,
file::DIFile, line::Integer, type::DIType,
expression::DIExpression; local_to_unit::Bool=false,
declaration=nothing,
align_in_bits::Integer=0) -> DIGlobalVariableExpressionCreate a new global variable descriptor paired with a DWARF expression.
LLVM.temp_global_variable_fwd_decl! — Function
temp_global_variable_fwd_decl!(builder::DIBuilder, scope::Union{DIScope,Nothing},
name::AbstractString, linkage::AbstractString,
file::DIFile, line::Integer, type::DIType;
local_to_unit::Bool=false, declaration=nothing,
align_in_bits::Integer=0)
-> TemporaryMDNode{DIGlobalVariable}Create a temporary forward declaration of a global variable, to be replaced with the variable (e.g., gve.variable of a global_variable_expression!) using replace_temporary!.
Imported entities
LLVM.DIImportedEntity — Type
DIImportedEntityAn imported entity, such as a C++ using declaration or module import.
LLVM.imported_module! — Function
imported_module!(builder::DIBuilder, scope::Union{DIScope,Nothing}, ns::DINamespace,
file::DIFile, line::Integer) -> DIImportedEntity
imported_module!(builder::DIBuilder, scope::Union{DIScope,Nothing},
entity::Union{DIModule,DIImportedEntity}, file::DIFile, line::Integer;
elements::AbstractVector=Metadata[]) -> DIImportedEntityCreate a new DIImportedEntity that imports a namespace (like C++'s using namespace), a module, or an alias of another imported entity into scope. The elements of an imported module or alias are its renamed entities.
LLVM.imported_declaration! — Function
imported_declaration!(builder::DIBuilder, scope::Union{DIScope,Nothing}, decl::DINode,
file::DIFile, line::Integer, name::AbstractString;
elements::AbstractVector=Metadata[])
-> DIImportedEntityCreate a new DIImportedEntity that imports the declaration decl (e.g., a variable, subprogram or type) into scope, as name (like C++'s using).
Macros
LLVM.DIMacro — Type
DIMacroA single preprocessor macro definition or undefinition.
LLVM.DIMacroFile — Type
DIMacroFileA collection of macro records corresponding to a single source file.
LLVM.macro! — Function
macro!(builder::DIBuilder, parent_macrofile::Union{DIMacroFile,Nothing},
line::Integer, record_type, name::AbstractString,
value::AbstractString) -> DIMacroCreate a new DIMacro. record_type is a LLVMDWARFMacinfoRecordType value (e.g. LLVM.API.LLVMDWARFMacinfoRecordTypeDefine).
LLVM.temp_macro_file! — Function
temp_macro_file!(builder::DIBuilder,
parent_macrofile::Union{DIMacroFile,Nothing},
line::Integer, file::DIFile) -> DIMacroFileCreate a new temporary DIMacroFile, for use as the parent of macro!. Unlike other temporary nodes, the builder replaces it when it is finalized, which invalidates the returned node.
Instruction-level insertion
Debug records are inserted at an InsertionPoint. The functions that insert them return an Instruction on LLVM ≤ 18 (legacy llvm.dbg.* intrinsics) and a LLVM.DbgRecord on LLVM ≥ 19 (the new #dbg_* record format). On LLVM 20 and later, dbg_label!(dib, label, location, pos) inserts a label record.
LLVM.dbg_declare! — Function
dbg_declare!(builder::DIBuilder, storage::Value, var::DILocalVariable,
expr::DIExpression, debugloc::DILocation,
pos::InsertionPoint{Instruction})Insert a debug record that declares storage as the address of the variable var at the given position, e.g., LLVM.after(alloca). Returns a DbgRecord on LLVM ≥ 19, or the llvm.dbg.declare call Instruction on LLVM < 19.
Debug records can not be inserted at the end of a block that has a terminator; use LLVM.before(bb.terminator) instead. Several records inserted at a position that is before the debug records of an instruction (e.g., LLVM.after(inst) or LLVM.at_begin(bb)) end up in reverse order, as each one is inserted in front of the others. Use LLVM.before(inst) to append records to the ones of inst.
LLVM.dbg_value! — Function
dbg_value!(builder::DIBuilder, val::Value, var::DILocalVariable,
expr::DIExpression, debugloc::DILocation,
pos::InsertionPoint{Instruction})Insert a debug record that describes val as the value of the variable var at the given position. Returns a DbgRecord on LLVM ≥ 19, or the llvm.dbg.value call Instruction on LLVM < 19. See dbg_declare! for which positions can be used.
LLVM.DbgRecord — Type
DbgRecordA non-instruction debug record attached to a basic block, replacing the legacy llvm.dbg.* intrinsics in LLVM ≥ 19. Requires LLVM 19+.
Properties
record.kindThe kind of the debug record, an LLVM.API.LLVMDbgRecordKind: LLVMDbgRecordDeclare, LLVMDbgRecordValue or LLVMDbgRecordAssign for variable records, which describe the location of a source variable, or LLVMDbgRecordLabel for label records.
Variable records can be further inspected using the following properties:
record.variable: the source variable that is described;record.expression: the expression that computes the variable's location;record.value: the IR value used by that expression, orrecord.location_operandsfor expressions that use several values.
The source location of every record is available as record.debug_location.
record.debug_locationThe source location of the debug record.
record.variableThe source variable described by a variable record.
record.expressionThe expression that computes the location of the variable described by a variable record, in terms of its location_operands.
record.location_operandsThe IR values that are used to compute the location of the variable described by a variable record, as a read-only view. There is usually only one, but records that use a !DIArgList can refer to several. Entries are nothing if the value has been deleted.
record.valueThe IR value used to compute the location of the variable described by a variable record, or nothing if that value has been deleted. Records that refer to several values need to be inspected using their location_operands instead.
record.next
record.prevThe next or previous debug record attached to the same instruction, or nothing if there is none. prev requires LLVM 20+.
LLVM.DILabel — Type
DILabelA debug-info label, describing a source-level code location by name. Requires LLVM 20+.
LLVM.label! — Function
label!(builder::DIBuilder, scope::DILocalScope, name::AbstractString,
file::DIFile, line::Integer;
always_preserve::Bool=false) -> DILabelCreate a new DILabel. Requires LLVM 20+.
LLVM.dbg_label! — Function
dbg_label!(builder::DIBuilder, label::DILabel, location::DILocation,
pos::InsertionPoint{Instruction}) -> DbgRecordInsert a debug record for the label label at the given position. See dbg_declare! for which positions can be used. Requires LLVM 20+.
The debug location of an instruction is available as its debug_location property (see inst.debug_location).
Compile Unit
LLVM.DICompileUnit — Type
DICompileUnitA compilation unit in the source code.
Properties
cu.emission_kindThe amount of debug info that is emitted for the compile unit, as a LLVM.DebugEmissionKind.T value: NoDebug, FullDebug, LineTablesOnly or DebugDirectivesOnly. Julia's code generator emits subprograms and locations even when it doesn't emit debug info, marking their compile unit NoDebug. This differs from the LLVM.DWARFEmissionKind.T that compile_unit! takes, which LLVM's C API defines without DebugDirectivesOnly.
The properties of DIScope, DINode and MDNode are available too.
LLVM.compile_unit! — Function
compile_unit!(builder::DIBuilder, lang, file::DIFile, producer::AbstractString;
optimized::Bool=true, cmdline::AbstractString="",
runtime_version::Integer=0,
split_name::Union{AbstractString,Nothing}=nothing,
emission_kind=LLVM.DWARFEmissionKind.Full,
dwo_id::Integer=0,
split_debug_inlining::Bool=true,
debug_info_for_profiling::Bool=false,
sysroot::AbstractString="", sdk::AbstractString="") -> DICompileUnitCreate a new DICompileUnit. lang is a LLVM.DWARFSourceLanguage.T value (e.g. LLVM.DWARFSourceLanguage.Julia). cmdline is a command-line string embedded verbatim in the emitted debug info.
Other
LLVM.DEBUG_METADATA_VERSION — Function
DEBUG_METADATA_VERSION()The current debug info version number, as supported by LLVM.
LLVM.strip_debuginfo! — Function
strip_debuginfo!(mod::Module)Strip the debug information from the given module.
The debug info of modules and functions is available as their debug_metadata_version and subprogram properties (see mod.debug_metadata_version and f.subprogram).