Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert a function in LLVM module

Tags:

c++

llvm

I am writing an LLVM pass, where I clone some functions by calling llvm::CloneFunction. Now I also want to insert those functions in the module. How can I do that?

like image 442
MetallicPriest Avatar asked Feb 04 '13 13:02

MetallicPriest


1 Answers

  • Create a new function with Function::Create or by other means. A Function's constructors accept a module into which to insert the new function.
  • Clone a function into that new function with CloneFunctionInto, or just copy over the BBs you need.
like image 168
Eli Bendersky Avatar answered Sep 25 '22 12:09

Eli Bendersky