[MLton] fixing -codegen c -profile time for the release
Thu, 17 Nov 2005 01:07:05 +1100
On Tue, 2005-11-15 at 20:47 -0800, Stephen Weeks wrote:
> It seems to me that the ideal fix is to figure out how to tell GCC
> exactly what we want, without inhibiting its optimization as much as
> possible. Unfortunately, as far as I can tell, no one has even
> proposed a way to do the former, let alone while simultaneously
> achieving the latter (in fact, this seems impossible).
I am not sure I fully understand .. but I believe I know
how to do this -- because Felix is already doing it.
So is Mercury .. which is where I stole it from.
The idea is explained in Fergus Henderson (et al)'s paper:
and involves inserting 'Assembler Labels' into the code
in such a way they cannot be elided. The paper describes
how to ensure this. For both Mercury and Felix the point
is to allow use of computed jumps, and has nothing to
do with profiling.
In Felix, I use these macros to generate assembler labels:
#define FLX_DECLARE_LABEL(n,i,x) \
extern void f##i##_##n##_##x(void) __asm__("l"#i"_"#n"_"#x);
#define FLX_LABEL(n,i,x) x:\
The first macro is required to *declare* each label at the
top of the file as an accessible C symbol for the purpose
of doing a computed jump to it. You may not need this.
The second actually generates the label in place, note carefully
the weird gcc annotations required to make certain it cannot
This particular macro takes three arguments, two integers and
a name, which serve only to support the Felix labelling
scheme. Note also on the first line of the second macro,
a normal 'C' label is also defined.
YMMV, but this demonstrates the technique you need I think.
Of course it ONLY works with gcc AND with a suitable GNU
assembler. Felix finds out if it works in the configure script
by trying it out.. :)
Hope this helps.
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net