Niddodi, Chaitra via llvm-dev
2019-Dec-16  04:07 UTC
[llvm-dev] Error while iterating over callee nodes in CallGraph
Despite making sure, it is not NULL, I still get a segmentation fault.
Code:
if((cgn->getFunction())==NULL)
        continue;
      errs()<<cgn->getFunction()->getName()<<"\n";
Error:
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.
Thanks,
Chaitra
________________________________
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>
Doerfert, Johannes via llvm-dev
2019-Dec-16  04:24 UTC
[llvm-dev] Error while iterating over callee nodes in CallGraph
On 12/16, Niddodi, Chaitra wrote:> Despite making sure, it is not NULL, I still get a segmentation fault. > > Code: > if((cgn->getFunction())==NULL) > continue; > errs()<<cgn->getFunction()->getName()<<"\n"; > > Error: > 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.Given that your LLVM version is pretty old I'm not sure this will work: The old/legacy pass manager is historically problematic when you cross IR unit boundaries. I would just create the call graph from scratch. I mean, use the CallGraph class but not the PM interface. That should work in modern LLVM just fine, e.g., via llvm::CallGraph(Module &M). To debug your segfault you might want to use a debug build of LLVM, even for the stack dump hat would probably help a lot.> ________________________________ > 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.-- Johannes Doerfert Researcher Argonne National Laboratory Lemont, IL 60439, USA jdoerfert at anl.gov -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 228 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191216/6e71e3a6/attachment.sig>