Automaticly eliminating redundant zero initialisers

From: Graham Stoney (greyham@research.canon.com.au)
Date: Mon May 01 2000 - 04:58:00 EST


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.

Thanks,
Graham

-- 
Graham Stoney
Principal Hardware/Software Engineer
Canon Information Systems Research Australia
Ph: +61 2 9805 2909  Fax: +61 2 9805 2929

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun May 07 2000 - 21:00:08 EST