Hi, There is a "Root" private member in CallGraph <http://llvm.org/docs/doxygen/html/CallGraph_8h_source.html#l00192> 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. Thanks, Riyad -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151208/28013898/attachment.html>
Howdy Riyad, 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. 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. If you want to obtain the Root pointer, you can consult the CallGraph::addToCallGraph method. http://llvm.org/docs/doxygen/html/CallGraph_8cpp_source.html 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. 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. Hope this helps and point out if I miss something. Kind regards, Kevin On Tue, Dec 8, 2015, 10:39 Riyad Parvez via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi, > > There is a "Root" private member in CallGraph > <http://llvm.org/docs/doxygen/html/CallGraph_8h_source.html#l00192> 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. > > Thanks, > Riyad > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151208/4c073efd/attachment.html>
Hi,> On Dec 8, 2015, at 8:38 AM, Riyad Parvez via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi, > > There is a "Root" private member in CallGraph <http://llvm.org/docs/doxygen/html/CallGraph_8h_source.html#l00192> 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.What is your use case? It may be possible to add an accessor. — Mehdi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151208/58b7f137/attachment.html>
On Tue, Dec 8, 2015 at 4:26 PM, Mehdi Amini <mehdi.amini at apple.com> wrote:> Hi, > > On Dec 8, 2015, at 8:38 AM, Riyad Parvez via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > Hi, > > There is a "Root" private member in CallGraph > <http://llvm.org/docs/doxygen/html/CallGraph_8h_source.html#l00192> 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. > > > > What is your use case? It may be possible to add an accessor. > >I want to topologically sort the call graph, just to have a sense of dependency between functions.> — > Mehdi > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151208/afad9917/attachment.html>