[LLVMdev] How to get a Module DSGraph?

Chris Lattner sabre at nondot.org
Sun Dec 1 12:15:01 PST 2002


On Sat, 30 Nov 2002, Juan Nicolas Ruiz wrote:
> I've been trying to obtain a DSGraph for a complete module, but
> haven't succeeded. I tried

First off, there is no one way to get a DSGraph for a module.  What you do
to get it depends on what kind of information you are interested in...

> - getting the DSGraph for each function, and copying the nodes to a
> Module graph. But since there are no nodehandles, apparently there is
> no merging of nodes.

This works fine, you just have to merge the formal and actual arguments
(and the return value) of functions with their call sites.  This ends up
giving you a "steensgaard's" style IP DSGraph.  In fact, if you look in
the DataStructure directory, the Steensgaards.cpp file contains a
(partial) implementation of this.  It doesn't handle function pointers or
any of that fun stuff yet, but you should be able to get the main idea
from it...

> My main interest is in situations like
>
> void *M(int size) {
>   return malloc(size);
> }
> void F() {
>    void *p = M(....);
> }

> where I can identify that %p and the object returned by M() are the
> same.

I'm not really sure what your ultimate goals are with this... because you
cannot represent that information so simply.  In a simple "one graph for
the entire module" approach, you completely lose calling context, so the
information you get might not be enough.  Then again, I don't know your
application, so it might be.  :)

Good luck,

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list