This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: redirect_edge_and_branch questions
On Mon, 2004-10-04 at 18:37, Zdenek Dvorak wrote:
> Hello,
>
> > > So what happens is that I redirect a bunch of edges to the new forwarder
> > > block, and any edges which aren't redirected get their PENDING_STMT list
> > > cleared. I might be able to work around this, but it is a tad annoying.
> > >
> > > When do we tell the cfg routines that we are not in SSA mode any more?
> > > Do they differentiate between SSA and trees at all?
> >
> > How serious would it break things if I taught ssa_redirect_edge that if
> > there are no PHI nodes, leave the edge list alone. or are their other
> > dependancies on that somewhere?
>
> this IMHO should work, but it is really not nice.
>
> > that seems a bit hacky tho.
>
> The clean way obviously would be not to use PENDING_STMT list for the
> purpose of remembering arguments of phi nodes on redirected edges.
> Which would mean adding a new field to edge to contain the phi node (and
> have extra memory overhead). Or old contents of PENDING_STMT could be
> preserved (held as a first member of the list, or something like that)
> and put back by the routines that arrange for the phi arguments to be
> put on their final location. Or redirect_edge could have some entirely
> different way of passing the arguments it removed to the caller
> (although I just now do not see a good way how to do it). Or we could
> request the phi arguments to be removed by the caller before calling
> redirect_edge.
>
> The last possibility seems best to me, although it would require
> changing all places where we handle phi node arguments in PENDING_STMT
> list.
>
What a can of worms :-)
tree_make_forwarder_block() *also* hacks around with PENDING_STMT and
automatically puts all those PENDING_STMTs into PHI args for me, or
tries to. How nice.
/* Add the arguments we have stored on edges. */
FOR_EACH_EDGE (e, ei, bb->preds)
{
if (e == fallthru)
continue;
for (phi = phi_nodes (bb), var = PENDING_STMT (e);
phi;
phi = PHI_CHAIN (phi), var = TREE_CHAIN (var))
add_phi_arg (&phi, TREE_VALUE (var), e);
PENDING_STMT (e) = NULL;
NOw this is all so I can do something that i could work around here.. I
can stash away all the stmts ahead of time and then not have top worry
about it. Im suprised other non-ssa tree CFG manipulations havent
tripped over it. Maybe Im just doing something weird.
For the moment, Im going to punt on it and simply save the stmts I care
about I think. I just want to move on at this point.
Andrew