Should optimizing compilers automatically assign registers?

Leo Willems leo at atcmp.nl
Tue May 8 05:53:11 AEST 1990


>From article <512 at hhb.UUCP>, by istvan at hhb.UUCP (Istvan Mohos):
> 
> 
	program deleted
> 
> Prog1 and prog2 are identical except that prog1 requests the
> assignment of the auto variable p to a hardware register.

 	and prog2 not.

> I mistakenly assumed that by using the -O flag, the compiler
> would optimize prog2, and generate identical objects from

	etc.

> 
> Is the automatic allocation of a few variables into registers
> too much to ask from an optimizing compiler?

Sorry for the rude deletion of text.

Our compiler with -O is putting automatic variables in registers. (3b2 SV 3.1)

But I have a question on this subject:

Should an optimizer put autovar's in a register anyway? 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.

This is in conflict with the manual page of setjmp/longjmp.
(I realise the setjmp/longjmp implementation is not very portable, but their
behaviour should be)

Is there an answer to this problem? (besides of not using setjmp/longjmp:-( )

Thanks


 Leo Willems			Internet: leo at atcmp.nl
 AT Computing			UUCP:     mcvax!hp4nl!kunivv1!atcmpe!leo
 P. O. Box 1428				
 6501 BK  Nijmegen		Phone:    +31-80-566880
 The Netherlands		Fax:	  +31-80-555887



More information about the Comp.unix.wizards mailing list