[LLVMdev] Inconsistent result with CallGraph

Eugenio Novás Cortés eugenio.novas at udc.es
Wed Nov 28 04:00:08 PST 2012


Hello:

We are working with LLVM-3.1 and we have a problem.This is the code we have
executed:

virtual void getAnalysisUsage( llvm::AnalysisUsage & info ) const {

   info.addRequired<CallGraph>();

   ...

}

...

virtual bool runOnModule( Module & M )

{

...

CallGraph &CG = this->getAnalysis<CallGraph>();

CallGraphNode *cgn;

unsigned nref;

for(CallGraph::const_iterator I=CG.begin(),E=CG.end();I!=E;I++)

{

    cgn=I->second;

    if((cgn)&&(cgn->getFunction()))

    {

          nref=cgn->getNumReferences();

          llvm::dbgs()<<"uses:"<<nref<<"\n";

          cgn->dump();

    }

}

...

}

In a simple program with only one function (Main), this is the output:

uses:0

Call graph node for function: 'main'<<0x7f928340c760>>  #uses=1


We have been searching in llvm files and dump function calls
getNumReferences() (which is in Callgraph.h). And it is assumed that the
call cgn->getNumReferences() references to the same function. Why are we
getting different values? Dump shows uses=1, and cgn->getNumReferences()
shows uses=0;

We are writing a Module pass as you can see in the previous code. We have
this pass registered as:

char PARALLWARE::ID = 0;

static RegisterPass<PARALLWARE> X( "parallware","run Parallware source to
source autoparallel compiler");


Is this a bug or we are making a mistake?

Thank you for your time. Best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121128/a7e7ab6b/attachment.html>


More information about the llvm-dev mailing list