Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Mar 1999 21:09:10 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        "Andrew Reilly" <andrew@lake.com.au>, "Stephen J. Roznowski" <sjr@home.net>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Use of "register" in code
Message-ID:  <199903160509.VAA06242@apollo.backplane.com>
References:  <199903160333.WAA06493@istari.home.net> <199903160349.TAA05543@apollo.backplane.com> <19990316151744.A39973@reilly.home> 

next in thread | previous in thread | raw e-mail | index | archive | help

:
:
::> :
::> :Thanks,
::> :-- 
::> :Stephen J. Roznowski    (sjr@home.net)
::> 
::>     The register declarations are useless historical artifacts.
::
::Why do you say that?  "register" in a declaration has a specific
::semantic meaning that isn't (to my knowledge) duplicated by any
::other language mechanism, and that is "this variable does not exist
::in the memory space, and so _cannot_ be de-referenced with "&" or
::modified by an asignment through a pointer."  Register pointer
::variables and temporaries are very important for preventing C
::compilers from producing pessimistic inner loop code.
::
::-- 
::Andrew
:
:    Firstly, that is not what register means.  Secondly, all modern C 
:    compilers that I know about, including one I wrote years ago, can 
:    trivially detect the stack locality of a variable and put it in a
:    register as part of standard optimizations.   It's one of the *easiest*
:    optimizations a C compiler can do, in fact.
:
:    Some compilers will add a little weight to the potential optimization
:    if you use the 'register' keyword, but modern compilers tend to do a
:    better job without the manual weighting.
:
:					-Matt
:					Matthew Dillon 
:					<dillon@backplane.com>

    Let me extend this with another example:  Protection against aliasing
    is not usually an issue with stack variables.  On the otherhand, it is
    something that would be much more useful with structural fields 
    or globals.

    Try putting the 'register' keyword in front of a structural field or
    global and you will wind up with a fist full of fatal compiler errors.

    I don't know a single programmer who uses 'register' to mean 'alias
    protection'.

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>





To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199903160509.VAA06242>