[LLVMdev] [LLVMDEV]How could I get function name in this situation?

John Criswell criswell at illinois.edu
Wed Jan 26 12:11:42 PST 2011


On 1/26/11 2:07 PM, songlh at cs.wisc.edu wrote:
> Hi:
>
>    My llvm code is:
>
>    for( BasicBlock::iterator i = b->begin() , ie = b->end();
>         b != be ; b ++ ){
>         if( CallInst * pCall = dyn_cast<CallInst>(i)){
>
>            pCall->dump(); //
>            Function * pFunction = pCall->getCalledFunction();
>            if( !pFunction ){
>
>            }
>            std::string fname = pFunction->getName();
>         }
>    }
>
>    The dump result of the function call I want to find is :
>
>    call void %7(%struct.nsAString* %8, i32 0) nounwind, !dbg !1565

This is a call using a function pointer.  There is no function name to 
retrieve.  You can check the called value (pcall->getCalledValue()) and 
see if it's something like a cast instruction that casts a constant 
function value, but that case is probably unlikely.

-- John T.

>    it returns null from pCall->getCalledFunction(), and I cannot get the
> function name.
>
>    How could I get the function name in this situation?
>
>    thanks a lot!
>
>                                          Linhai
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list