[llvm-dev] How to extract functions from Module A and put them into Module B, and generate a new IR file?

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 22 11:39:14 PDT 2018


On 3/22/2018 11:28 AM, shen Liu via llvm-dev wrote:
> Hi all,
>
> This is Michael and very happy to share my question here!
>
> My question is, is there a way to "extract" a function from Module A 
> and write it into another Module B, and generate two new IR files? 
> IRBuilder seems like a workable way but I have to create instructions 
> one by one. I am new to LLVM so don't know whether it is doable, here 
> is my experimental code:

Correctly moving functions between modules is tricky in general; I'd 
suggest using one of the existing utilities to do it.  See 
include/llvm/Linker/Linker.h and include/llvm/Linker/IRMover.h.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list