[patch] bsi_for_stmt

Dale Johannesen dalej@apple.com
Mon Aug 30 20:42:00 GMT 2004


On Aug 30, 2004, at 12:38 PM, Jeffrey A Law wrote:

> On Mon, 2004-08-30 at 13:27, Zdenek Dvorak wrote:
>> Hello,
>>
>>>> this patch implements the function that enables to obtain an 
>>>> iterator
>>>> for the statement in constant time.  This functionality seems to be
>>>> needed in several new patches (ivopts, Andrew Pinski's loops to 
>>>> memset
>>>> optimization pass, Dale Johannesen's implemenation of value 
>>>> profiling
>>>> on tree level).
>>>>
>>> Could you provide some examples?  In principle, I don't see why an
>>> object should know about its container.  When I've needed to 
>>> manipulate
>>> statements, I just pass around SIs.
>
> You'd need the bsi if you were going to remove the original statement
> and replace it with a new one, or if you were going to move the
> original statement from one location to a new location, or if you
> were going to insert a new statement somewhere.

This is the case in value profiling.  The value profiler makes an early 
pass over
the gimple, finding trees that look interesting and remembering them.
Later it makes a second pass and possibly replaces the originals, in 
some
cases with multiple blocks worth of stmts.  The natural way to do it is 
record
the stmt node, and create a bsi corresponding to that node later.  I 
did try
saving the bsi, because I didn't like introducing bsi_for_stmt either, 
but
once you've done one replacement, the bsi's for other stmts aren't 
useful
any more.  (Plus, copying bsi's around is not so great for efficiency 
either.)



More information about the Gcc-patches mailing list