This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] computed goto edges
- From: Jason Merrill <jason at redhat dot com>
- To: "Jeffrey A. Law" <law at redhat dot com>
- Cc: Andrew MacLeod <amacleod at redhat dot com>, gcc at gcc dot gnu dot org, Jason Merrill <jason at redhat dot com>
- Date: Wed, 02 Jul 2003 16:02:30 -0400
- Subject: [tree-ssa] computed goto edges
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