llvm::MDNode

Metadata node.

Synopsis

Declared in <llvm/IR/Metadata.h>

class MDNode
    : public Metadata

Description

Metadata nodes can be uniqued, like constants, or distinct. Temporary metadata nodes (with full support for RAUW) can be used to delay uniquing until forward references are known. The basic metadata node is an MDTuple.

There is limited support for RAUW at construction time. At construction time, if any operand is a temporary node (or an unresolved uniqued node, which indicates a transitive temporary operand), the node itself will be unresolved. As soon as all operands become resolved, it will drop RAUW support permanently.

If an unresolved node is part of a cycle, resolveCycles() needs to be called on some member of the cycle once all temporary nodes have been replaced.

MDNodes can be large or small, as well as resizable or non-resizable. Large MDNodes' operands are allocated in a separate storage vector, whereas small MDNodes' operands are co-allocated. Distinct and temporary MDnodes are resizable, but only MDTuples support this capability.

Clients can add operands to resizable MDNodes using push_back().

Base Classes

NameDescription
MetadataRoot of the metadata hierarchy.

Type Aliases

Name
op_iterator
op_range

Enums

Name
MetadataKind

Member Functions

NameDescription
MDNode [constructor] [deleted]Copy constructor
operator= [deleted]
clone Create a (temporary) clone of this.
dump User-friendly dump.
dumpTree User-friendly dump in tree shape.
getContext
getMetadataID
getNumOperands Return number of MDNode operands.
getNumTemporaryUses
getOperand
isAlwaysReplaceable
isDistinct
isReplaceable
isResolved Check if node is fully resolved.
isTBAAVtableAccess Check whether MDNode is a vtable access.
isTemporary
isUniqued
op_begin
op_end
operands
operator new [deleted]
print Print.
printAsOperand Print as operand.
printTree Print in tree shape.
replaceAllUsesWith RAUW a temporary.
replaceOperandWith Replace a specific operand.
resolve Resolve a unique, unresolved node.
resolveCycles Resolve cycles.

Static Member Functions

NameDescription
classof Methods for support type inquiry through isa, cast, and dyn_cast:
concatenate Methods for metadata merging.
deleteTemporary Deallocate a node created by getTemporary.
fromCaptureComponents Convert CaptureComponents to !captures metadata. The return value may be nullptr.
get
getDistinct
getIfExists
getMergedAllocTokenMetadata
getMergedCalleeTypeMetadata
getMergedCallsiteMetadata
getMergedMemProfMetadata
getMergedProfMetadata Merge !prof metadata from two instructions. Currently only implemented with direct callsites with branch weights.
getMostGenericAliasScope
getMostGenericAlignmentOrDereferenceable
getMostGenericFPMath
getMostGenericNoFPClass
getMostGenericNoaliasAddrspace
getMostGenericRange
getMostGenericTBAA
getTemporary
intersect
replaceWithDistinct Replace a temporary node with a distinct one.
replaceWithPermanent Replace a temporary node with a permanent one.
replaceWithUniqued Replace a temporary node with a uniqued one.
toCaptureComponents Convert !captures metadata to CaptureComponents. MD may be nullptr.

Static Data Members

NameDescription
PoisonGeneratingIDs Metadata IDs that may generate poison.

Protected Type Aliases

Name
mutable_op_range

Protected Enums

NameDescription
StorageType Active type of storage.

Protected Member Functions

NameDescription
MDNode [constructor]
~MDNode [destructor]Destructor
dropAllReferences
getNumUnresolved
handleChangedOperand Default handling of a changed operand, which asserts.
mutable_begin
mutable_end
mutable_operands
operator delete Required by std, but never called.
operator new
resize Resize the node to hold NumOps operands.
setNumUnresolved
setOperand Set an operand.
storeDistinctInContext

Protected Static Member Functions

Name
storeImpl

Protected Data Members

NameDescription
Storage Storage flag for non-uniqued, otherwise unowned, metadata.
SubclassData1
SubclassData16
SubclassData32

Friends

NameDescription
llvm::DIAssignIDAssignment ID. Used to link stores (as an attachment) and dbg.assigns (as an operand). DIAssignID metadata is never uniqued as we compare instances using referential equality (the instance/address is the ID).
llvm::LLVMContextImpl
llvm::ReplaceableMetadataImplShared implementation of use-lists for replaceable metadata.

Non-Member Functions

NameDescription
MapMetadataLookup or compute a mapping for a piece of metadata.
MapMetadataVersion of MapMetadata with type safety for MDNode.
UpgradeTBAANodeIf the given TBAA tag uses the scalar TBAA format, create a new node corresponding to the upgrade to the struct-path aware TBAA format. Otherwise return the TBAANode itself.
computeKnownBitsFromRangeMetadataCompute known bits from the range metadata. KnownZero the set of bits that are known to be zero KnownOne the set of bits that are known to be one
extractBranchWeightsExtract branch weights from MD_prof metadata
extractFromBranchWeightMD32Faster version of extractBranchWeights() that skips checks and must only be called with "branch_weights" metadata nodes. Supports uint32_t.
extractFromBranchWeightMD64Faster version of extractBranchWeights() that skips checks and must only be called with "branch_weights" metadata nodes. Supports uint64_t.
extractProfTotalWeightRetrieve the total of all weights from MD_prof data.
findOptionMDForLoopFind string metadata for a loop.
findOptionMDForLoopIDFind and return the loop attribute node for the attribute Name in LoopID. Return nullptr if there is no such attribute.
getBranchWeightMDNodeGet the branch weights metadata node
getBranchWeightOffsetReturn the offset to the first branch weight data
getConstantRangeFromMetadataParse out a conservative ConstantRange from !range metadata.
getDISubprogramFind subprogram that is enclosing this scope.
getExplicitlyUnknownBranchWeightsIfProfiledReturns a metadata node containing unknown branch weights if the function has an entry count, otherwise returns nullptr.
getMemCacheHintMetadataReturn the cache hint metadata node for memory operand OperandNo on I, or nullptr when the instruction has no hint for that operand. For a CallBase, OperandNo is an argument index; otherwise it is an instruction operand index.
getPGOFuncNameMetadataReturn the PGOFuncName meta data associated with a function.
getValidBranchWeightMDNodeGet the valid branch weights metadata node
hasBranchWeightOriginCheck if Branch Weight Metadata has an "expected" field from an llvm.expect* intrinsic
intersectAccessGroupsCompute the access-group list of access groups that Inst1 and Inst2 are both in. If either instruction does not access memory at all, it is considered to be in every list.
isBranchWeightMDChecks if an MDNode contains Branch Weight Metadata
isValidAsAccessGroupReturn whether an MDNode might represent an access group.
isValueProfileMDChecks if an MDNode contains value profiling Metadata
makeFollowupLoopIDCreate a new loop identifier for a loop created from a loop transformation.
makePostTransformationMetadataCreate a new LoopID after the loop has been transformed.
uniteAccessGroupsCompute the union of two access-group lists.
upgradeInstructionLoopAttachmentUpgrade the loop attachment metadata node.
memprof::buildCallstackMetadataBuild callstack metadata from the provided list of call stack ids. Returns the resulting metadata node.
memprof::getMIBAllocTypeReturns the allocation type from an MIB metadata node.
memprof::getMIBStackNodeReturns the stack node from an MIB metadata node.

Derived Classes

NameDescription
DIAssignID Assignment ID. Used to link stores (as an attachment) and dbg.assigns (as an operand). DIAssignID metadata is never uniqued as we compare instances using referential equality (the instance/address is the ID).
DIExpression DWARF expression.
DIGlobalVariableExpression A pair of DIGlobalVariable and DIExpression.
DILocation Debug location.
DIMacroNode Macro Info DWARF-like metadata node.
DINode Tagged DWARF-like metadata node.
MDTuple Tuple of metadata.