LLVM 22.0.0git
Public Member Functions | List of all members
llvm::ValueMapper Class Reference

Context for (re-)mapping values (and metadata). More...

#include "llvm/Transforms/Utils/ValueMapper.h"

Public Member Functions

LLVM_ABI ValueMapper (ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr, const MetadataPredicate *IdentityMD=nullptr)
 
 ValueMapper (ValueMapper &&)=delete
 
 ValueMapper (const ValueMapper &)=delete
 
ValueMapperoperator= (ValueMapper &&)=delete
 
ValueMapperoperator= (const ValueMapper &)=delete
 
LLVM_ABI ~ValueMapper ()
 
LLVM_ABI unsigned registerAlternateMappingContext (ValueToValueMapTy &VM, ValueMaterializer *Materializer=nullptr)
 Register an alternate mapping context.
 
LLVM_ABI void addFlags (RemapFlags Flags)
 Add to the current RemapFlags.
 
LLVM_ABI MetadatamapMetadata (const Metadata &MD)
 
LLVM_ABI MDNodemapMDNode (const MDNode &N)
 
LLVM_ABI ValuemapValue (const Value &V)
 
LLVM_ABI ConstantmapConstant (const Constant &C)
 
LLVM_ABI void remapInstruction (Instruction &I)
 
LLVM_ABI void remapDbgRecord (Module *M, DbgRecord &V)
 
LLVM_ABI void remapDbgRecordRange (Module *M, iterator_range< DbgRecordIterator > Range)
 
LLVM_ABI void remapFunction (Function &F)
 
LLVM_ABI void remapGlobalObjectMetadata (GlobalObject &GO)
 
LLVM_ABI void scheduleMapGlobalInitializer (GlobalVariable &GV, Constant &Init, unsigned MappingContextID=0)
 
LLVM_ABI void scheduleMapAppendingVariable (GlobalVariable &GV, Constant *InitPrefix, bool IsOldCtorDtor, ArrayRef< Constant * > NewMembers, unsigned MappingContextID=0)
 
LLVM_ABI void scheduleMapGlobalAlias (GlobalAlias &GA, Constant &Aliasee, unsigned MappingContextID=0)
 
LLVM_ABI void scheduleMapGlobalIFunc (GlobalIFunc &GI, Constant &Resolver, unsigned MappingContextID=0)
 
LLVM_ABI void scheduleRemapFunction (Function &F, unsigned MappingContextID=0)
 

Detailed Description

Context for (re-)mapping values (and metadata).

A shared context used for mapping and remapping of Value and Metadata instances using ValueToValueMapTy, RemapFlags, ValueMapTypeRemapper, ValueMaterializer, and IdentityMD.

There are a number of top-level entry points:

The ValueMaterializer can be used as a callback, but cannot invoke any of these top-level functions recursively. Instead, callbacks should use one of the following to schedule work lazily in the ValueMapper instance:

Sometimes a callback needs a different mapping context. Such a context can be registered using registerAlternateMappingContext(), which takes an alternate ValueToValueMapTy and ValueMaterializer and returns a ID to pass into the schedule*() functions.

If an IdentityMD predicate is optionally provided, Metadata for which the predicate returns true will be mapped onto itself in VM on first use.

TODO: lib/Linker really doesn't need the ValueHandle in the ValueToValueMapTy. We should template ValueMapper (and its implementation classes), and explicitly instantiate on two concrete instances of ValueMap (one as ValueToValueMap, and one with raw Value pointers). It may be viable to do away with TrackingMDRef in the Metadata side map for the lib/Linker case as well, in which case we'll need a new template parameter on ValueMap.

TODO: Update callers of RemapInstruction() and MapValue() (etc.) to use ValueMapper directly.

Definition at line 163 of file ValueMapper.h.

Constructor & Destructor Documentation

◆ ValueMapper() [1/3]

ValueMapper::ValueMapper ( ValueToValueMapTy VM,
RemapFlags  Flags = RF_None,
ValueMapTypeRemapper TypeMapper = nullptr,
ValueMaterializer Materializer = nullptr,
const MetadataPredicate IdentityMD = nullptr 
)

Definition at line 1221 of file ValueMapper.cpp.

◆ ValueMapper() [2/3]

llvm::ValueMapper::ValueMapper ( ValueMapper &&  )
delete

◆ ValueMapper() [3/3]

llvm::ValueMapper::ValueMapper ( const ValueMapper )
delete

◆ ~ValueMapper()

ValueMapper::~ValueMapper ( )

Definition at line 1227 of file ValueMapper.cpp.

References getAsMapper().

Member Function Documentation

◆ addFlags()

void ValueMapper::addFlags ( RemapFlags  Flags)

Add to the current RemapFlags.

Note
Like the top-level mapping functions, addFlags() must be called at the top level, not during a callback in a ValueMaterializer.

Definition at line 1235 of file ValueMapper.cpp.

◆ mapConstant()

Constant * ValueMapper::mapConstant ( const Constant C)

Definition at line 1243 of file ValueMapper.cpp.

References llvm::CallingConv::C, and mapValue().

Referenced by llvm::MapValue().

◆ mapMDNode()

MDNode * ValueMapper::mapMDNode ( const MDNode N)

Definition at line 1251 of file ValueMapper.cpp.

References mapMetadata(), and N.

Referenced by llvm::MapMetadata().

◆ mapMetadata()

Metadata * ValueMapper::mapMetadata ( const Metadata MD)

Definition at line 1247 of file ValueMapper.cpp.

Referenced by mapMDNode(), and llvm::MapMetadata().

◆ mapValue()

Value * ValueMapper::mapValue ( const Value V)

Definition at line 1239 of file ValueMapper.cpp.

Referenced by mapConstant(), and llvm::MapValue().

◆ operator=() [1/2]

ValueMapper & llvm::ValueMapper::operator= ( const ValueMapper )
delete

◆ operator=() [2/2]

ValueMapper & llvm::ValueMapper::operator= ( ValueMapper &&  )
delete

◆ registerAlternateMappingContext()

unsigned ValueMapper::registerAlternateMappingContext ( ValueToValueMapTy VM,
ValueMaterializer Materializer = nullptr 
)

Register an alternate mapping context.

Returns a MappingContextID that can be used with the various schedule*() API to switch in a different value map on-the-fly.

Definition at line 1230 of file ValueMapper.cpp.

References getAsMapper().

◆ remapDbgRecord()

void ValueMapper::remapDbgRecord ( Module M,
DbgRecord V 
)

Definition at line 1259 of file ValueMapper.cpp.

Referenced by llvm::RemapDbgRecord(), and remapDbgRecordRange().

◆ remapDbgRecordRange()

void ValueMapper::remapDbgRecordRange ( Module M,
iterator_range< DbgRecordIterator Range 
)

Definition at line 1263 of file ValueMapper.cpp.

References Range, and remapDbgRecord().

Referenced by llvm::RemapDbgRecordRange().

◆ remapFunction()

void ValueMapper::remapFunction ( Function F)

Definition at line 1270 of file ValueMapper.cpp.

References F.

Referenced by llvm::RemapFunction().

◆ remapGlobalObjectMetadata()

void ValueMapper::remapGlobalObjectMetadata ( GlobalObject GO)

Definition at line 1274 of file ValueMapper.cpp.

◆ remapInstruction()

void ValueMapper::remapInstruction ( Instruction I)

Definition at line 1255 of file ValueMapper.cpp.

References I.

Referenced by llvm::RemapInstruction().

◆ scheduleMapAppendingVariable()

void ValueMapper::scheduleMapAppendingVariable ( GlobalVariable GV,
Constant InitPrefix,
bool  IsOldCtorDtor,
ArrayRef< Constant * >  NewMembers,
unsigned  MappingContextID = 0 
)

Definition at line 1284 of file ValueMapper.cpp.

References getAsMapper().

◆ scheduleMapGlobalAlias()

void ValueMapper::scheduleMapGlobalAlias ( GlobalAlias GA,
Constant Aliasee,
unsigned  MappingContextID = 0 
)

Definition at line 1293 of file ValueMapper.cpp.

References getAsMapper().

◆ scheduleMapGlobalIFunc()

void ValueMapper::scheduleMapGlobalIFunc ( GlobalIFunc GI,
Constant Resolver,
unsigned  MappingContextID = 0 
)

Definition at line 1298 of file ValueMapper.cpp.

References getAsMapper().

◆ scheduleMapGlobalInitializer()

void ValueMapper::scheduleMapGlobalInitializer ( GlobalVariable GV,
Constant Init,
unsigned  MappingContextID = 0 
)

Definition at line 1278 of file ValueMapper.cpp.

References getAsMapper().

◆ scheduleRemapFunction()

void ValueMapper::scheduleRemapFunction ( Function F,
unsigned  MappingContextID = 0 
)

Definition at line 1303 of file ValueMapper.cpp.

References F, and getAsMapper().


The documentation for this class was generated from the following files: