[LLVMdev] A few beginner level questions..

Misha Brukman brukman at uiuc.edu
Thu Nov 18 09:41:04 PST 2004


On Thu, Nov 18, 2004 at 03:19:35PM +0800, Abhijit Ray wrote:
> 2. For an application , for every instruction if its a call
> instruction I try to print out the called function as below ..
> 
> void pass01a::instruct_show(Instruction* I){
>    if ( isa<CallInst>(*I) ){
>        const CallInst     *CI      = cast<CallInst>(I);
>        const Function    *Func  = CI->getCalledFunction() ;
>        std::cerr<<":calledFunction:"<<Func->getName();
>    }
> }
> 
> Now it works fine for some application but for one of the benchmark in
> MIBENCH , i am getting the following error ..

In a debugger like gdb, you can use the function ->dump() on any Value*
to print it out to std::err, so with some breakpoints, you could look at
what CI is, and if it's OK (i.e., valid), step to the next statement and
look at what Func is, before you call Func->getName().

As Reid pointed out, it could be that CI or Func is null or invalid, it
could be your bug if you have modified them somehow, or if it is a bug
in an LLVM pass, please narrow it down (using bugpoint) and file it as
such.

-- 
Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu




More information about the llvm-dev mailing list