[tree-ssa] computed goto edges
Jason Merrill
jason@redhat.com
Wed Jul 2 20:07:00 GMT 2003
make_goto_expr_edges says,
/* The RTL CFG code got this wrong. A computed goto creates
normal edges, except for one case. Namely a computed goto
in a nested function has an abnormal edge to the exit block
(which is handled elsewhere). */
But how do you split critical edges from a computed goto like the ones in
gcc.c-torture/execute/920302-1.c? You have code like
static void *tab[] = {&&x, &&y, &&z};
x: *bp++='x';
goto *(base + *ip++);
y: *bp++='y';
goto *(base + *ip++);
z: *bp++='z';
*bp=0;
return;
(where base+*ip is some value from tab[]).
So we have two gotos which jump to the same three labels through an array.
The only plausible way I can think of to split one of these edges would be
to do a switch on the destination address and jump to the split label
instead. Until we do that, I think we need to consider these edges
abnormal.
Currently, when the compiler tries to add code on one of these edges, it
just inserts it after the goto, which is obviously broken.
Interestingly, however, it is trying to add the same code on each of the
outgoing edges, so that the .optimized dump looks like
...
goto F.18;;
ip = F.14;
bp = F.13;
ip = F.14;
bp = F.13;
bp = F.13;
y:;;
...
It seems like unssa should also detect the case where all incoming or
outgoing edges have the same phi node, so splitting is unnecessary.
BTW, if you're wondering, this situation is produced by a patch to always
evaluate non-trivial expressions into temps.
Jason
More information about the Gcc
mailing list