<font color="#000000"><span style="font-family:arial,sans-serif;font-size:13px">Hello:</span><br style="font-family:arial,sans-serif;font-size:13px"></font><div class="gmail_quote" style="font-family:arial,sans-serif;font-size:13px">

<font color="#000000"><br>We are working with LLVM-3.1 and we have a problem.This is the code we have executed:</font><div><div class="im"><p></p><p></p><p><font color="#000000">virtual void getAnalysisUsage( llvm::AnalysisUsage & info ) const {</font></p>

<p><font color="#000000">   info.addRequired<CallGraph>();</font></p><p><font color="#000000">   ...</font></p><p><font color="#000000">}</font></p><p><font color="#000000">...</font></p><p></p><p><font color="#000000">virtual bool runOnModule( Module & M )</font></p>

<p><font color="#000000">{</font></p><p><font color="#000000">...</font></p><p></p><p></p><p><font color="#000000">CallGraph &CG = this->getAnalysis<CallGraph>();</font></p><p></p><p><font color="#000000">CallGraphNode *cgn;</font></p>

<p><font color="#000000">unsigned nref;<br></font></p><p><font color="#000000">for(CallGraph::const_iterator I=CG.begin(),E=CG.end();I!=E;I++)</font></p><p><font color="#000000">{</font></p><p><font color="#000000">    cgn=I->second;</font></p>

<p><font color="#000000">    if((cgn)&&(cgn->getFunction()))</font></p><p><font color="#000000">    {</font></p><p><font color="#000000">          nref=cgn->getNumReferences();</font></p><p><font color="#000000">          llvm::dbgs()<<"uses:"<<nref<<"\n";</font></p>

<p><font color="#000000">          cgn->dump();</font></p><p><font color="#000000">    }</font></p><p><font color="#000000">}</font></p><p><font color="#000000">...</font></p><p><font color="#000000">}</font></p></div>

<p><font color="#000000">In a simple program with only one function (Main), this is the output:</font></p><div class="im"><p></p><p><font color="#000000">uses:0</font></p><p><font color="#000000">Call graph node for function: 'main'<<0x7f928340c760>>  #uses=1</font></p>

</div><p><font color="#000000"><br>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;</font></p>

<div class="im"><p><font color="#000000">We are writing a Module pass as you can see in the previous code. We have this pass registered as:</font></p><p></p><p><font color="#000000">char PARALLWARE::ID = 0;</font></p><p>
<font color="#000000">static RegisterPass<PARALLWARE> X( "parallware","run Parallware source to source autoparallel compiler");</font></p>
<p><font color="#000000"><br></font></p></div><p><font color="#000000">Is this a bug or we are making a mistake?</font></p><p></p><p><font color="#000000">Thank you for your time. Best regards</font><br></p><p></p></div>
</div>