[LLVMdev] the called function equal NULL

John McCall rjmccall at apple.com
Mon Nov 29 17:26:10 PST 2010


On Nov 29, 2010, at 5:22 PM, huwei8717 wrote:

> Hi,
>  
> I have a llvm-pass in hand written by other people. There are following statements that I couldn't understand:
>  
> -------------------------------program----------------------------------------------------
> ...
> if (isa<CallInst>(inst) || isa<InvokeInst>(inst)) {
>     const CallSite cs(inst);
>     if (cs.getCalledFunction() == NULL)
>       return dealAtIndirectCall(cs);
>     else
>       return dealAtDirectCall(cs);
> }
> ...
> -------------------------------------------------------------------------------------------
>  
> My question is:
>  
> When does the called function equal NULL, could you give an example?  I mean what kind of call in source code could change to this case in llvm-IR, could you give an example?

A call to a value of function-pointer type, e.g.
  void callit(void (*f)()) { f(); }

Virtual calls in C++ would also have no known called function.

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101129/74dc2a75/attachment.html>


More information about the llvm-dev mailing list