James Courtier-Dutton via llvm-dev
2018-Jun-13 09:31 UTC
[llvm-dev] Cloning a function from one module to another module
Hi, Say I have loaded two .bc files into memory so that I have 2 modules. How could I clone a function from one module into the other module. I have looked at: Function *CloneFunction(Function *F, ValueToValueMapTy &VMap, ClonedCodeInfo *CodeInfo = nullptr); But I think that only clones within the same Module, not between modules. I believe the clone between modules will take more effort, because all the associated types will need to also be cloned if they are not already in the destination module. I can implement this myself, but I wished to check that it had not already been done before. Kind Regards James
Serge Guelton via llvm-dev
2018-Jun-13 10:01 UTC
[llvm-dev] Cloning a function from one module to another module
On Wed, Jun 13, 2018 at 10:31:59AM +0100, James Courtier-Dutton via llvm-dev wrote:> Hi, > > Say I have loaded two .bc files into memory so that I have 2 modules. > How could I clone a function from one module into the other module. > > I have looked at: > Function *CloneFunction(Function *F, ValueToValueMapTy &VMap, > ClonedCodeInfo *CodeInfo = nullptr); > > But I think that only clones within the same Module, not between modules. > I believe the clone between modules will take more effort, because all > the associated types will need to also be cloned if they are not > already in the destination module.You can probably use llvm::Linker::linkInModule to do the merging,it takes care of the types and deps and such.