[LLVMdev] Inconsistent result with CallGraph

Duncan Sands baldrick at free.fr
Wed Nov 28 04:52:51 PST 2012


Hi Eugenio, I took a quick look at the 3.2 code and as far as I can see it is
impossible to get what you get.  So I suggest you try running under valgrind
to see if you are using freed memory or something like that.

Ciao, Duncan.

On 28/11/12 13:00, Eugenio Novás Cortés wrote:
> 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
>
>
>
> _______________________________________________
> 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