This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: EH clobbered by longjmp again
- To: Richard Henderson <rth at cygnus dot com>
- Subject: Re: EH clobbered by longjmp again
- From: Jim Wilson <wilson at chestnut dot cygnus dot com>
- Date: Fri, 05 Sep 1997 20:17:32 -0700
- cc: egcs at cygnus dot com
BTW: is there no code in gcc to do basic block reordering? Is
this just something that has never come up?
There is code in loop.c that can detect a basic block inside a loop that ends
with an unconditional branch outside the loop, and then move this entire block
outside the loop thus making the loop smaller.
There is some code in jump.c that can simplify `if (foo) bar; else break;'
to `if (!foo) break; bar;', thus eliminating an unconditional branch.
Otherwise, no, there isn't code that does basic block reordering. Spaghetti
code that would benefit from it is rare in practice, though it looks like
we will see a bit of it when builtin setjmp/longjmp are used.
It seems like it should be rather easy to rearrange things such
that block-pairs that have such a one-to-one relationship are
placed ajacent to one another so that the unconditional jump can
be avoided.
There are a few complications that can make it harder than it appears.
If you have exception regions (-fno-sjlj-exceptions), then you don't want
to move code in or out of an exception region.
If you are emitting debuggging info, then moving a basic block out of
its lexical block may seriously confuse the debugging info. Most debug
info formats can't handle this. Dwarf can, but gcc doesn't have the
necessary code to support this dwarf feature.
If one of the blocks contains a loop start, continue point, or loop end, then
moving the block could confuse the loop structure, hurting loop based
optimizations.
If the blocks are at different loop nesting levels, then it is OK to move
a block from an inner loop to an outer loop, but not from an outer loop to
an inner loop. (We already have some code to do this.) If the blocks are
in different loops at the same nesting level, then you probably don't want
to move either one.
I could come up with more cases if I stopped to think about it.
Anyways, yes, if you are careful to avoid any case that might cause problems,
then it should be pretty easy to handle this. The code in jump.c could
probably be used as a good starting point for this. Search for the
string `if (foo) bar; else break;' to find it.
Jim