This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Automaticly eliminating redundant zero initialisers
- To: Tigran Aivazian <tigran at veritas dot com>
- Subject: Re: Automaticly eliminating redundant zero initialisers
- From: George Anzinger <george at pioneer dot net>
- Date: Mon, 01 May 2000 04:30:05 -0700
- Cc: Graham Stoney <greyham at research dot canon dot com dot au>,Russell King <rmk at arm dot linux dot org dot uk>,Linux kernel mailing list <linux-kernel at vger dot rutgers dot edu>,gcc at gcc dot gnu dot org
- Organization: Monta Vista Software
- References: <Pine.LNX.4.21.0005011126350.1079-100000@saturn.homenet>
Tigran Aivazian wrote:
>
> On Mon, 1 May 2000, Tigran Aivazian wrote:
> > On Mon, 1 May 2000, Graham Stoney wrote:
> >
> > > In a discussion about Linux kernel optimisations, Russell King writes:
> > > > Oh, if any of the mm people are reading this, what about killing the
> > > > redundant zero initialisers so that these variables can be placed in
> > > > the BSS?
> > >
> > > Even better, is there any way to get gcc to treat static and extern variables
> > > with explicit all-bits-zero initializers as though they had no initializers?
> > >
> > > In other words, treat these the same:
> > > static int initialised=0; /* wastes space in .data */
> > > static int uninitialised; /* implicitly zero, and more efficient */
> > >
> > > This would be useful for all space-conscious environments where the user
> > > knows that .bss is zero-filled. Variables with redundant explicit zero
> > > initializers are effectively wasting .data space, but some programmer like
> > > to use them anyway.
> >
> > # cd /usr/src/linux/arch/i386/kernel
> > # grep -i surprise *S
> > head.S: * Clear BSS first so that there are no surprises...
> >
> > as you see, it has been done explicitly by the kernel, regardless of what
> > gcc may have prepared.
>
> oops, I just realised you are asking for something slightly different.
> What I meant is that you can now safely ignore zero-initializers because
> BSS is zero-cleared by the kernel explicitly.
>
> Regards,
> Tigran
Soon as you depend on this some OS dude will fill bss with -1s so he can
tell what was used... or some such. Seems like a bad idea to depend on
bss being anything at all.
George