Related articles |
---|
register variables in C. eric@pencom.com (1992-04-22) |
register variables in C. kennykb@dssv01.crd.ge.com (1992-04-22) |
Re: register variables in C. moss@cs.umass.edu (1992-04-23) |
Re: register variables in C. dd@mips.com (1992-04-23) |
Re: register variables in C. dave.howell@ColumbiaSC.NCR.COM (Dave Howell) (1992-04-24) |
Re: register variables in C. bart@cs.uoregon.edu (1992-04-29) |
Re: register variables in C. jeff@dsp.sps.mot.com (1992-04-30) |
Re: register variables in C. Brian.Scearce@Eng.Sun.COM (1992-04-30) |
[9 later articles] |
Newsgroups: | comp.compilers |
From: | kennykb@dssv01.crd.ge.com |
Keywords: | C, optimize, registers |
Organization: | Compilers Central |
References: | 92-04-108 |
Date: | Wed, 22 Apr 1992 21:13:50 GMT |
In article 92-04-108 eric@pencom.com writes:
>In other words, should a programmer ever use the "register" storage class?
>[My impression is that the compiler can do a much better job, particularly
>with a graph coloring register allocator, but I'd be interested in some
>real data. -John]
The `register' declaration can provide an important hint to the optimizer
-- that no pointer ever points to the variable in question.
Data flow analysis for determining what variables can be altered by an
assignment through a pointer is complicated. Many compilers simply beg
the question and assume that anything at all can be trashed by a pointer
assignment -- or by a function call, since the function (which is
unavailable at compile time) might contain an assignment through a global
pointer that designates the variable.
I'm having trouble remembering the specifics, but I seem to recall that
there was a case where a simple static check that the & (address-of)
operator fails to detect an aliasing problem. The `register' declaration
functions as an assertion that there is no aliasing problem for a given
variable.
Do any other readers remember more about this?
73 de ke9tv/2, Kevin
[It's true that "register" may be useful as an assertion, but I'm very
sceptical of any claims that a compiler can't reliably identify statically
unaliased variables. If it couldn't, there'd be no way to generate
reliably correct object code even with register declarations since on most
architectures registers don't have addresses. -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.