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?
-
I am trying to find an LLVM API function that does that, but still am unable to find one.MetallicPriest– MetallicPriest2013-02-04 13:06:05 +00:00Commented Feb 4, 2013 at 13:06
Add a comment
|
3 Answers
- Create a new function with
Function::Createor by other means. AFunction'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.
Comments
CloneFunction will automatically insert the new Function into the old Function's module. From the doxygen:
Return a copy of the specified function and add it to that function's module.