[llvm-dev] Error while iterating over callee nodes in CallGraph

Niddodi, Chaitra via llvm-dev llvm-dev at lists.llvm.org
Sun Dec 15 20:07:19 PST 2019

Despite making sure, it is not NULL, I still get a segmentation fault.


0  opt             0x00000000011d2302 llvm::sys::PrintStackTrace(_IO_FILE*) + 34
1  opt             0x00000000011d1eb4
2  libpthread.so.0 0x00007fea1847c330
3  libcgwalk.so     0x00007fea1767f596
4  opt             0x00000000010ddb45 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 709
5  opt             0x0000000000552724 main + 2452
6  libc.so.6       0x00007fea178a4f45 __libc_start_main + 245
7  opt             0x000000000056d865
Stack dump:
0. Program arguments: opt -load build/proj/libcgwalk.so -cgwalk
1. Running pass 'Cgwalk' on module '<stdin>'.
Segmentation fault (core dumped)

Also, using getName() on the main function prints out an empty string - errs()<<cg[M.getFunction("main")]->getFunction()->getName()<<"\n";
There seems to be some issue with CallGraph generation.


From: Doerfert, Johannes
Sent: Sunday, December 15, 2019 8:38 PM
To: Niddodi, Chaitra
Cc: llvm-dev at lists.llvm.org
Subject: Re: [llvm-dev] Error while iterating over callee nodes in CallGraph

On 12/15, Niddodi, Chaitra via llvm-dev wrote:
>   for (CallGraphNode::iterator ti = cgm->begin(); ti != cgm->end(); ++ti)
>      {
>       CallGraphNode * cgn = ti->second;
>       if(cgn==NULL)
>         continue;
>       errs()<<cgn->getFunction()<<"\n";
>       errs()<<cgn->getFunction()->getName()<<"\n";

I think the function (cgn->getFunction()) can be NULL (to indicate
special edges). Make sure it isn't.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191216/fa363ab0/attachment.html>

More information about the llvm-dev mailing list