llvm::MapMetadata

Lookup or compute a mapping for a piece of metadata.

Synopsis

Declared in <llvm/Transforms/Utils/ValueMapper.h>

Metadata*
MapMetadata(
    Metadata const* MD,
    ValueToValueMapTy& VM,
    RemapFlags Flags = RF_None,
    ValueMapTypeRemapper* TypeMapper = nullptr,
    ValueMaterializer* Materializer = nullptr,
    MetadataPredicate const* IdentityMD = nullptr);

Description

Compute and memoize a mapping for MD.

1. If MD is mapped, return it. 2. Else if RF_NoModuleLevelChanges or MD is an MDString, return MD. 3. Else if MD is a ConstantAsMetadata, call MapValue() and re-wrap its return (returning nullptr on nullptr). 4. Else if IdentityMD predicate returns true for MD then add an identity mapping for it and return it. 5. Else, MD is an MDNode. These are remapped, along with their transitive operands. Distinct nodes are duplicated or moved depending on RF_MoveDistinctNodes. Uniqued nodes are remapped like constants.

NOTE

LocalAsMetadata is completely unsupported by MapMetadata. Instead, use MapValue() with its wrapping MetadataAsValue instance.

Return Value

Root of the metadata hierarchy.

Parameters

NameDescription
MDRoot of the metadata hierarchy.
FlagsThese are flags that the value mapping APIs allow.
TypeMapperThis is a class that can be implemented by clients to remap types when cloning constants and instructions.
MaterializerThis is a class that can be implemented by clients to materialize Values on demand.