This patch reduces the on-disk size of binaries by placing zero-filled
string variables to .bss.
Consider the following example:
static char filename1[MAXPATHNAME] = "";
static char filename2[MAXPATHNAME] = "";
...
static char filenameN[MAXPATHNAME] = "";
where MAXPATHNAME is a big number, 1024 or more is not uncommon.
Currently, GCC puts all these arrays into the .data section and
allocates chunks of zero-filled space for them. This is a shame
considering that the `""' initializers expand to '\0' and, thus, the
variables can be safely placed into .bss section instead. Data in the
.bss section is always zero-initialized before the program starts, so
there is no need to keep initialization image in the binary.
The tree.c:initializer_zerop() predicate is the one responsible for
identifying initializers that are sole zeroes at runtime.
This patch teaches GCC that `""', `"\0"', `"\0\0"', etc. are all
equivalent to zeroes.
The patch was bootstrapped and regtested on x86_64-linux-gnu (all
languages except ada) with no regressions.
OK for 4.6?
The patch is simple enough to be considered for 4.5, but this is RMs'
call.
Thank you,