LLVM  5.0.0
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

 ValueMapper (ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
 
 ValueMapper (ValueMapper &&)=delete
 
 ValueMapper (const ValueMapper &)=delete
 
ValueMapper & operator= (ValueMapper &&)=delete
 
ValueMapper & operator= (const ValueMapper &)=delete
 
 ~ValueMapper ()
 
unsigned registerAlternateMappingContext (ValueToValueMapTy &VM, ValueMaterializer *Materializer=nullptr)
 Register an alternate mapping context. More...
 
void addFlags (RemapFlags Flags)
 Add to the current RemapFlags. More...
 
Metadata * mapMetadata (const Metadata &MD)
 
MDNode * mapMDNode (const MDNode &N)
 
Value * mapValue (const Value &V)
 
Constant * mapConstant (const Constant &C)
 
void remapInstruction (Instruction &I)
 
void remapFunction (Function &F)
 
void scheduleMapGlobalInitializer (GlobalVariable &GV, Constant &Init, unsigned MappingContextID=0)
 
void scheduleMapAppendingVariable (GlobalVariable &GV, Constant *InitPrefix, bool IsOldCtorDtor, ArrayRef< Constant * > NewMembers, unsigned MappingContextID=0)
 
void scheduleMapGlobalAliasee (GlobalAlias &GA, Constant &Aliasee, unsigned MappingContextID=0)
 
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, and ValueMaterializer.

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.

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 134 of file ValueMapper.h.

Constructor & Destructor Documentation

ValueMapper::ValueMapper ( ValueToValueMapTy &  VM,
RemapFlags  Flags = RF_None,
ValueMapTypeRemapper *  TypeMapper = nullptr,
ValueMaterializer *  Materializer = nullptr 
)

Definition at line 1046 of file ValueMapper.cpp.

llvm::ValueMapper::ValueMapper ( ValueMapper &&  )
delete
llvm::ValueMapper::ValueMapper ( const ValueMapper &  )
delete
ValueMapper::~ValueMapper ( )

Definition at line 1051 of file ValueMapper.cpp.

References getAsMapper().

Member Function Documentation

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 1059 of file ValueMapper.cpp.

Constant * ValueMapper::mapConstant ( const Constant &  C)

Definition at line 1067 of file ValueMapper.cpp.

References mapValue().

Referenced by llvm::MapValue().

MDNode * ValueMapper::mapMDNode ( const MDNode &  N)

Definition at line 1075 of file ValueMapper.cpp.

References mapMetadata().

Referenced by llvm::MapMetadata().

Metadata * ValueMapper::mapMetadata ( const Metadata &  MD)

Definition at line 1071 of file ValueMapper.cpp.

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

Value * ValueMapper::mapValue ( const Value &  V)

Definition at line 1063 of file ValueMapper.cpp.

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

ValueMapper& llvm::ValueMapper::operator= ( ValueMapper &&  )
delete
ValueMapper& llvm::ValueMapper::operator= ( const ValueMapper &  )
delete
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 1054 of file ValueMapper.cpp.

References getAsMapper().

void ValueMapper::remapFunction ( Function &  F)

Definition at line 1083 of file ValueMapper.cpp.

Referenced by llvm::RemapFunction().

void ValueMapper::remapInstruction ( Instruction &  I)

Definition at line 1079 of file ValueMapper.cpp.

Referenced by llvm::RemapInstruction().

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

Definition at line 1093 of file ValueMapper.cpp.

References getAsMapper().

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

Definition at line 1102 of file ValueMapper.cpp.

References getAsMapper().

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

Definition at line 1087 of file ValueMapper.cpp.

References getAsMapper().

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

Definition at line 1107 of file ValueMapper.cpp.

References getAsMapper().


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