[llvm-dev] Why getFunction() of CallGraphNode return NULL function?

Nema, Ashutosh via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 19 04:23:49 PST 2016


You will see NULL for indirect callSite.
May need to add additional checks for this possibility.

Regards,
Ashutosh

From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Qiuping Yi via llvm-dev
Sent: Tuesday, January 19, 2016 5:35 PM
To: llvm-dev at lists.llvm.org
Subject: [llvm-dev] Why getFunction() of CallGraphNode return NULL function?

Hi all,

I want to find all the called functions in each function, thus I iterate the calledFunctions of each CallGraphNode in CallGraph as follow:

for (CallGraph::iterator it = CG->begin(); it != CG->end(); ++it) {
   CallGraphNode* node = it->second;
   for (CallGraphNode::iterator it2 = node->begin(); it2 != node->end(); ++it2) {
      Function* calledFunc = it2->second=>getFunction();
      cerr << ”function: “ << calledFunc->getName().str() <<"\n";  // crash some times
      ... ...
      ... ...
    }
}

I found that some time "calledFunc" is NULL function and thus the output crash. I don't known why? If the before code is wrong, so what is the correct method for get all the called functions?

I use LLVM 3.6. Thank you all in advance.

--------------------------------------------
Qiuping Yi
Institute Of Software
Chinese Academy of Sciences
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160119/2a04b4d3/attachment.html>


More information about the llvm-dev mailing list