[patch 2/7] enable unit-at-a-time optimisations for gcc4

Arjan van de Ven
2006-01-06T10:45:28Z

Subject: allow gcc4 to optimize unit-at-a-time

From: Ingo Molnar <mingo@elte.hu>

allow gcc4 compilers to optimize unit-at-a-time.

This flag enables gcc to "see" the entire C file before making optimisation
decisions such as inline, which results in gcc making better decisions. One
of the immediate effects of this is that static functions that are used only
once now get inlined.

gcc 3.4 has this flag as well, however gcc 3.x have a problem with inlining
and stacks and as a result, enabling this flag there would cause excessive
and unacceptable stack use. This problem is fixed in the gcc 4.x series.
The x86-64 architecture already enables this feature so it's well tested
already.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@infradead.org>

----

arch/i386/Makefile | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6.15/arch/i386/Makefile
===================================================================
--- linux-2.6.15.orig/arch/i386/Makefile
+++ linux-2.6.15/arch/i386/Makefile
@@ -42,9 +42,9 @@ include $(srctree)/arch/i386/Makefile.cp
GCC_VERSION := $(call cc-version)
cflags-$(CONFIG_REGPARM) += $(shell if [ $(GCC_VERSION) -ge 0300 ] ; then echo "-mregparm=3"; fi ;)

-# Disable unit-at-a-time mode, it makes gcc use a lot more stack
-# due to the lack of sharing of stacklots.
-CFLAGS += $(call cc-option,-fno-unit-at-a-time)
+# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
+# a lot more stack due to the lack of sharing of stacklots:
+CFLAGS += $(shell if [ $(GCC_VERSION) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;)

CFLAGS += $(cflags-y)