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

From: Horst von Brand (vonbrand@inf.utfsm.cl)
Date: Tue Nov 28 2000 - 06:25:36 EST


Andrea Arcangeli <andrea@suse.de> 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:vonbrand@inf.utfsm.cl
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513  
  
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Nov 30 2000 - 21:00:19 EST