2000-11-28 11:56:39

by Horst H. von Brand

[permalink] [raw]
Subject: Re: [PATCH] removal of "static foo = 0"

Andrea Arcangeli <[email protected]> said:
> On Mon, Nov 27, 2000 at 02:34:45PM -0500, Richard B. Johnson wrote:
> > The following shell-script shows that gcc-2.8.1 produces code with
> > data allocations adjacent. However, they are reversed!

> same with 2.95.* :).

The point was if gcc did use the fact that variables are adyacent in memory
to generate better code, and this degenerated into the current discussion
about where they are from the programmers perspective.

- If gcc is going to use the fact that some variables are nearby for some
optimization purposes, I do trust the gcc hackers to set stuff up so that
they use it for variables that are nearby in VM, not just where defined
together. If variables defined together end up adyacent or not is
completely irrelevant. The compiler might even rearrange them to
optimize for the access pattern observed.
- As a C programmer, you are only entitled to assume that pieces of the
same object (array or struct) are laid out in memory in the order
given. With segmented VM different objects would probably end up in
different segments anyway.
--
Dr. Horst H. von Brand mailto:[email protected]
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513