[patch] bsi_for_stmt

Jeffrey A Law law@redhat.com
Mon Aug 30 19:59:00 GMT 2004


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.
> 
> suppose you want to replace a statement defining a SSA name by some
> other computation.  From ssa name you get the defining statement, but to
> replace it, you need a bsi.  Passing around BSI's is cumbersome, slow,
> and sometimes even wrong (in case cfg is manipulated, BSI's may become
> invalid, if the statement they point to moves to a different basic
> block).
But if you're replacing the expression used to in the statement
defining an SSA_NAME, it seems to me you don't need the bsi.  You
could just modify the existing statement in place.

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.

jeff




More information about the Gcc-patches mailing list