[LLVMdev] Find mallocs from a DSNode

Scott Mikula mikula at uiuc.edu
Sun Nov 10 22:51:01 PST 2002


Chris Lattner wrote:

> > Is there some efficient way to find the malloc instructions which point
> > to the memory represented by a DSNode?  Right now the only way I see is
> > by iterating through the value map in the DSGraph object and finding
> > every value that points to my DSNode.
>
> You're right, you have to iterate over the program, looking to see what
> DSNodes the Malloc instructions point to.  This is intentional: keeping
> track of this information would cause a huge representational problem.
> Sorry :)

Fair enough.

> > A possibly related question: is there a way to tell that the node has
> > been merged, and if so, what types of nodes went into the merge?
>
> Yup, DSNode::NodeType contains flags for the node.  There are four flags
> that indicate the composition of the node: DSNode::AllocaNode, HeapNode,
> GlobalNode, UnknownNode.
>
> When two nodes are merged, their Flags are bitwise or'd together...

I realized that, but what if two nodes of the same type are merged?  Their
flags will not indicate that a merge has occurred.  I'm concerned about the
case where two malloc nodes are merged, because then if free is called on the
memory represented by that node, you cannot be certain of either malloc's
memory being freed.  I suppose after I iterate over the value map I'll see
that two malloc instructions point to the same DSNode, which will give me the
equivalent information.

Thanks,
Scott




More information about the llvm-dev mailing list