[tree-ssa] Walking blocks in reverse

Diego Novillo dnovillo@redhat.com
Fri Apr 4 21:55:00 GMT 2003


On Fri, 04 Apr 2003, Andrew Macleod wrote:

> Is this OK to check in? Or would you rather I keep it local to the live
> range code for now?
> 
The only time I've needed to walk blocks backwards I've done
something similar.  In tree-ssa.c:rewrite_block we need to walk
back undoing certain things we did on the forward walk.  What we
do there is while doing the forward walk keep a stack of the
events we will want to unwind at the end.  This way we avoid
walking *all* the statements.

I guess you can't do something similar in the live range code,
right?

So, I think it's fine.  I was thinking of another alternative,
have bsi_last() do the forward walk creating the stack which is
then stashed in the iterator.  Then bsi_prev() will just unwind the
stack.  But that would mean adding another word to the block
iterator structure.  Which penalizes every use of the iterators.

Your approach is better because it's only needed when some pass
needs to walk a block backwards.


Diego.



More information about the Gcc-patches mailing list