I am trying to traverse the call graph. Once I get a node in the call graph, I am trying to print the function name corresponding to that call graph node as well as the number of references.
1)The function name is always an empty string.
2)The number of references is always a random number.
3)Also the called functions names are also an empty string.
bool runOnModule(llvm::Module &M) override
CallGraph cg = CallGraph(M);
cg.dump();// this is correct. It is printing the expected the call graph
for ( CallGraph::const_iterator itr = cg.begin(), ie = cg.end() ; itr != ie; itr++)
if (itr->second != nullptr)
CallGraphNode *cgn = itr->second.get();
if(const Function* fptr = cgn->getFunction())
errs()<<“Number of references are”<getNumReferences()<<"\n";