mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
Extend RemapInstruction and friends to take an optional new parameter, a ValueMaterializer.
Extend LinkModules to pass a ValueMaterializer to RemapInstruction and friends to lazily create Functions for lazily linked globals. This is a big win when linking small modules with large (mostly unused) library modules. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182776 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -131,7 +131,8 @@ void CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
|
||||
SmallVectorImpl<ReturnInst*> &Returns,
|
||||
const char *NameSuffix = "",
|
||||
ClonedCodeInfo *CodeInfo = 0,
|
||||
ValueMapTypeRemapper *TypeMapper = 0);
|
||||
ValueMapTypeRemapper *TypeMapper = 0,
|
||||
ValueMaterializer *Materializer = 0);
|
||||
|
||||
/// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto,
|
||||
/// except that it does some simple constant prop and DCE on the fly. The
|
||||
|
@@ -33,6 +33,19 @@ namespace llvm {
|
||||
/// remap types while mapping values.
|
||||
virtual Type *remapType(Type *SrcTy) = 0;
|
||||
};
|
||||
|
||||
/// ValueMaterializer - This is a class that can be implemented by clients
|
||||
/// to materialize Values on demand.
|
||||
class ValueMaterializer {
|
||||
virtual void anchor(); // Out of line method.
|
||||
public:
|
||||
virtual ~ValueMaterializer() {}
|
||||
|
||||
/// materializeValueFor - The client should implement this method if they
|
||||
/// want to generate a mapped Value on demand. For example, if linking
|
||||
/// lazily.
|
||||
virtual Value *materializeValueFor(Value *V) = 0;
|
||||
};
|
||||
|
||||
/// RemapFlags - These are flags that the value mapping APIs allow.
|
||||
enum RemapFlags {
|
||||
@@ -55,23 +68,29 @@ namespace llvm {
|
||||
|
||||
Value *MapValue(const Value *V, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags = RF_None,
|
||||
ValueMapTypeRemapper *TypeMapper = 0);
|
||||
ValueMapTypeRemapper *TypeMapper = 0,
|
||||
ValueMaterializer *Materializer = 0);
|
||||
|
||||
void RemapInstruction(Instruction *I, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags = RF_None,
|
||||
ValueMapTypeRemapper *TypeMapper = 0);
|
||||
ValueMapTypeRemapper *TypeMapper = 0,
|
||||
ValueMaterializer *Materializer = 0);
|
||||
|
||||
/// MapValue - provide versions that preserve type safety for MDNode and
|
||||
/// Constants.
|
||||
inline MDNode *MapValue(const MDNode *V, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags = RF_None,
|
||||
ValueMapTypeRemapper *TypeMapper = 0) {
|
||||
return cast<MDNode>(MapValue((const Value*)V, VM, Flags, TypeMapper));
|
||||
ValueMapTypeRemapper *TypeMapper = 0,
|
||||
ValueMaterializer *Materializer = 0) {
|
||||
return cast<MDNode>(MapValue((const Value*)V, VM, Flags, TypeMapper,
|
||||
Materializer));
|
||||
}
|
||||
inline Constant *MapValue(const Constant *V, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags = RF_None,
|
||||
ValueMapTypeRemapper *TypeMapper = 0) {
|
||||
return cast<Constant>(MapValue((const Value*)V, VM, Flags, TypeMapper));
|
||||
ValueMapTypeRemapper *TypeMapper = 0,
|
||||
ValueMaterializer *Materializer = 0) {
|
||||
return cast<Constant>(MapValue((const Value*)V, VM, Flags, TypeMapper,
|
||||
Materializer));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user