[llvm-dev] Cloning a function from one module to another module
Serge Guelton via llvm-dev
llvm-dev at lists.llvm.org
Wed Jun 13 03:01:29 PDT 2018
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.
More information about the llvm-dev
mailing list