<p dir="ltr">Howdy Riyad,</p>
<p dir="ltr">The Root pointer in CallGraph represents either the "main" function CallGraph node, or the ExternalCallingNode, when the main function doesn't exist in the module.</p>
<p dir="ltr">I don't see a public API to this pointer in the header, but the Callgraph::print function could print out info for the node, including if the Root has a function related to it or it's null.</p>
<p dir="ltr">If you want to obtain the Root pointer, you can consult the CallGraph::addToCallGraph method.</p>
<p dir="ltr"><a href="http://llvm.org/docs/doxygen/html/CallGraph_8cpp_source.html">http://llvm.org/docs/doxygen/html/CallGraph_8cpp_source.html</a></p>
<p dir="ltr">In short, while it adds the new node it determine if the new node is main function. The Root is pointed to main node if and only if there's only one main node added to CallGraph. It points to ExternalCallingNode when there are multiple main functions or no main at all.</p>
<p dir="ltr">You can iterate through the CallGraph to get all functions to decide what Root really is. In this way you should get the same results as what LLVM is doing right now.</p>
<p dir="ltr">Hope this helps and point out if I miss something.<br></p>
<p dir="ltr">Kind regards,<br>
Kevin</p>
<br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 8, 2015, 10:39 Riyad Parvez via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>There is a "Root" private member in <a href="http://llvm.org/docs/doxygen/html/CallGraph_8h_source.html#l00192" target="_blank">CallGraph</a> class. But there is no way to get access to that member. How can I do that? I can get CallGraphNode of "main" method. But I am curious is there more cleaner way.</div><div><br></div><div>Thanks,</div><div>Riyad</div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>