This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
BB reordering question
- From: Archie Cobbs <archie at dellroad dot org>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 30 Jan 2004 17:57:39 -0600 (CST)
- Subject: BB reordering question
Hi,
I have a simple question that hopefully has a simple answer...
I'm using GCC (gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5))
for x86 to compile machine generated code that looks like this:
function()
{
const void *lables[] = { &&label1, &&label2, &&label3, ... };
label1:
blah blah
if (blah)
goto label3;
blah
label2:
blah
..
if (blah)
goto *labels[i];
...
label3:
blah
...
...
}
At the end of each basic block, control either flows into the next
basic block, there is a return from the function, or there is a call
to another non-returning function marked __attribute__((noreturn)).
A requirement states that the labels[] array must be sorted in strictly
ascending order (all basic blocks are nonempty). But I'd also like to
enable as many optimizations as possible. So my question is, what is
the best choice of optimizations that won't reorder any blocks, ever?
I've tried "-O2 -fno-reorder-blocks"; it *almost* works but not quite.
E.g. if the last BB terminates with a call to a noreturn function,
GCC will still reorder it, presumably so an epilogue is at the end
of the function in memory (I saw some related (?) mailing list
comments: http://gcc.gnu.org/ml/gcc-patches/2002-05/msg02293.html).
First, is this a bug, feature, or am I confused about what the
"-fno-reorder-blocks" flag is supposed to do?
Is there some other way for me to get the desired result other than
disabling optimzation altogether?
Would getting rid of all the __attribute__((noreturn))'s be a valid
workaround for the "-O2 -fno-reorder-blocks" reordering problem?
Thanks for any insights.
-Archie
P.S. please CC me with any responses (I'm not subscribed yet)
__________________________________________________________________________
Archie Cobbs * Halloo Communications * http://www.halloo.com