[llvm-dev] Replacing a function from one module into another one

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 28 11:26:20 PDT 2018


On 8/27/2018 10:37 AM, Daniel Moya via llvm-dev wrote:
> Hello LLVM Developers,
>
> I'm trying to replace a function defined in one module into another 
> module (different files). The first issue I ran into was that 
> llvm::Function does not have a method "moveBefore" or "moveAfter" as 
> the llvm::BasicBlock or llvm::Instruction do, so I figured I would 
> just move the BasicBlocks of the replacing function into the function 
> that was being replaced, and then eliminate the original BasicBlocks.

Cross-module operations are tricky in general; I'd suggest using the 
Linker::linkModules API if possible.

-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