[LLVMdev] Re: questions (fwd)

Chris Lattner sabre at nondot.org
Thu Nov 21 11:49:01 PST 2002


FYI, this may be useful to others...

>     Quick question. I have a CallInst *, how do i know if its a direct
> function call or a call via a function pointer?

if (Function *F = dyn_cast<Function>(CI->getOperand(0))) {
  it's a direct call

> If it is a function pointer, is it easy to get all the possible
> functions that have the signature (i guess the DSGraph would be helpful
> here)?

No, there is no easy way.  Given a DSGraph, you could ask for the DSNode
corresponding to the function pointer, then get a list of globals in that
node.  That would provide the list you need.  Note that this is only valid
if the "incomplete" bit is not set on the node.  If it is, then you must
assume ALL functions can get called.

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list