[LLVMdev] How to get Function object in LLVM Pass
baldrick at free.fr
Thu Oct 25 04:16:06 PDT 2012
On 25/10/12 11:51, Rahul wrote:
> I am writing a llvm pass which inserts some code in a function.
> In code generation, I want to insert code for a function call. But for this, I
> need to get function object from list of functions available with Module.
> When I try to get the function object by specifying function name, it returns null.
> I suppose this happens because clang removes function prototypes if the function
> is not called in source file.
> Is there any way to retain the function prototypes in clang??
> Or is there a way to get it during llvm pass??
if you want to mark a function as being used, to prevent the compiler
eliminating it, give it the "used" attribute, __attribute__((used)).
More information about the llvm-dev