diff options
author | James Molloy <james.molloy@arm.com> | 2013-05-28 15:17:05 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2013-05-28 15:17:05 +0000 |
commit | a84a83bbcdfaecadfc6574094272fd3edc429a23 (patch) | |
tree | ca87000d15263653ac635164ab194745b87f46e6 /include | |
parent | 9903f75bf6ec4136bd752595c689db845eedad3d (diff) | |
download | llvm-a84a83bbcdfaecadfc6574094272fd3edc429a23.tar.gz llvm-a84a83bbcdfaecadfc6574094272fd3edc429a23.tar.bz2 llvm-a84a83bbcdfaecadfc6574094272fd3edc429a23.tar.xz |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Transforms/Utils/Cloning.h | 3 | ||||
-rw-r--r-- | include/llvm/Transforms/Utils/ValueMapper.h | 31 |
2 files changed, 27 insertions, 7 deletions
diff --git a/include/llvm/Transforms/Utils/Cloning.h b/include/llvm/Transforms/Utils/Cloning.h index 14212f622b..3ec132937c 100644 --- a/include/llvm/Transforms/Utils/Cloning.h +++ b/include/llvm/Transforms/Utils/Cloning.h @@ -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 diff --git a/include/llvm/Transforms/Utils/ValueMapper.h b/include/llvm/Transforms/Utils/ValueMapper.h index 5390c5e8ed..d56ac07690 100644 --- a/include/llvm/Transforms/Utils/ValueMapper.h +++ b/include/llvm/Transforms/Utils/ValueMapper.h @@ -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)); } |