Should optimizing compilers automatically assign registers?
Guy Harris
guy at auspex.auspex.com
Wed May 9 03:53:34 AEST 1990
>Should an optimizer put autovar's in a register anyway?
Yes, it should.
>If you use setjmp/longjmp, on the return from setjmp via longjmp, automatic
>variables can not be trusted any more! If they are not in a register
>everything is fine, but else the reg-var's are overwritten with registervalues
>which were there at the time of the longjmp call.
ANSI C says that unless you declare the automatic variables "volatile",
there's no guarantee that "setjmp"/"longjmp" will preserve them.
Sun's C compiler includes a #pragma "makes_regs_inconsistent", and on
the 68K-based Suns includes this #pragma when you include <setjmp.h>;
that #pragma suppresses the automatic register allocation in routines
that call the routines listed in the #pragma, and in the version used
when you include <setjmp.h>, "sigsetjmp", "setjmp", and "_setjmp" are
listed.
More information about the Comp.unix.wizards
mailing list