[LLVMdev] Getting the DSNode from a Pool Descriptor?
John Criswell
criswell at uiuc.edu
Fri Mar 19 08:11:18 PDT 2010
Patrick Simmons wrote:
> On 03/19/10 08:56, John Criswell wrote:
>
>> Patrick Simmons wrote:
>>
>>> Thanks for all your help so far.
>>>
>>> My problem is that what I have are the pool descriptors, which I by
>>> traversing the uses of poolinit and accessing the first argument of
>>> each call. I need to find the DSNode (in the original function) to
>>> which this pool descriptor corresponds. The rub is that this pool
>>> descriptor of course does not exist except in the clone.
>>>
>> One way to do this might be to search for a use of the pool within the
>> function (such as a poolalloc() or a function call that passes the
>> pool). You can then find a pointer that belongs to the pool, map that
>> pointer from the clone back to the original function, and then look up
>> its DSNode.
>>
>> However, before you do that, can you tell us why you need this
>> functionality? Since things are getting complicated, it may be
>> worthwhile to first understand if your approach of mapping Pools to
>> the DSNodes from which they were created is the correct approach for
>> what you are doing. If, for example, you need to know whether a pool
>> is a type-homogeneous, then an easier method would be to modify
>> poolinit() to pass an argument containing DSNode information (such as
>> a flag indicating type-homogeneity).
>>
>> -- John T.
>>
>
> I've thought of trying to do that, but that solution is really too ugly
> to live. I need this because NSPASS (my project) runs after DSA but
> before pool allocation and generates a list of DSNodes with a special
> property. Then, TPPA (still my project) needs to iterate over every
> pool, which it does by iterating over the uses of poolinit, and figure
> out whether that pool needs to be annotated in a special way based on
> whether the DSNode from whence it came had the special property. To do
> this, it needs to convert the pool descriptor it gets by taking the
> first argument of poolinit back into the DSNode it used to be and then
> check the information from NSPASS to see whether it needs a special
> annotation.
>
> Is there a better way to do this?
>
The pool allocation passes already have a function called getPool() that
should return the pool associated with a DSNode. Assuming that this
function works for the Automatic Pool Allocation pass (and if it
doesn't, we as a group can fix it), then you can do the following:
For every special DSNode
Pool = getPool (special DSNode)
Scan through uses of Pool to find the call to poolinit
Modify the call to poolinit
This algorithm may not be as efficient as the one you described (because
you'll be searching multiple use-def chains and, in some cases, will be
searching them for a poolinit that doesn't exist). However, the
algorithm should work, and the efficiency may still be good.
Another option would be to enhance the pool allocation passes to map a
pool back to the DSNode for which it was created. I don't think this
would be too difficult to do.
-- John T.
> Thanks,
> --Patrick
>
>
More information about the llvm-dev
mailing list