possible bug in llvm-3.1

Hello:

We are developer-engineers of Appentra Solutions. We are working with LLVM-3.1 and we have a problem. We think we have found a bug on CallGraphNode. This is the code we have executed:

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

info.addRequired();

}

virtual bool runOnModule( Module & M )

{

CallGraph &CG = this->getAnalysis();

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 X( “parallware”,“run Parallware source to source autoparallel compiler”);

Is this a bug or we are making a mistake?

Thank you for your time.
We wait for your reply. Please, contact us at this e-mail: eugenio.novas@udc.es.

Best regards.