[LLVMdev] Finding call points to a function

Nick Lewycky nicholas at mxc.ca
Wed Sep 9 23:36:38 PDT 2009

Rakesh Komuravelli wrote:
> Hi,
> I am writing an LLVM Pass and I would like to know how would I do the 
> following:
> 1. I have a function foo, and I need to get all the call points calling 
> this function in each Function of the Module. The only way I can think 
> of is to iterate over the BasicBlocks of each Function, look for all the 
> Call Instructions and check if the called function is foo. I was 
> wondering if there is any other better way to do this.

Iterate over @foo's use list. 

> 2. Is it possible to distinguish a class method from a non class method 
> while analyzing the emitted LLVM code for a C++ program? Because, I need 
> to interpret the calls made to foo differently in a class method and in 
> a non class method.

No. Methods turn into functions that happen to take the class type 
pointer as first argument.


More information about the llvm-dev mailing list