Lookup or compute a mapping for a piece of metadata.
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);
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.
LocalAsMetadata is completely unsupported by MapMetadata. Instead, use MapValue() with its wrapping MetadataAsValue instance.
The mapped metadata, or nullptr when mapping fails.
| Name | Description |
|---|---|
| MD | Metadata to look up or map. |
| VM | Mapping from original values to remapped values. |
| Flags | Remapping flags that control mapper behavior. |
| TypeMapper | Optional callback that remaps types while mapping values. |
| Materializer | Optional callback that materializes unmapped values. |
| IdentityMD | Optional predicate for metadata that maps onto itself. |