Re: GCC 3.4 and broken inlining.

Andi Kleen
2004-07-09T04:51:55Z

Nigel Cunningham <ncunningham@linuxmail.org> writes:

I think a better solution would be to apply the appended patch

And then just mark the function you know needs to be inlined
as __always_inline__. I did this on x86-64 for some functions
too that need to be always inlined (although using the attribute
directly because all x86-64 compilers support it)

The rationale is that the inlining algorithm in gcc 3.4+ is quite
a lot better and actually eliminates some not-so-great inlining
we had in the past and makes the kernel a bit smaller.

-Andi

P.S.: compiler.h seems to be not "gcc 4.0 safe". Probably that needs
to be fixed too.

diff -u linux-2.6.7-bk9-work/include/linux/compiler.h-o linux-2.6.7-bk9-work/include/linux/compiler.h
--- linux-2.6.7-bk9-work/include/linux/compiler.h-o 2004-07-08 23:58:54.000000000 +0200
+++ linux-2.6.7-bk9-work/include/linux/compiler.h 2004-07-09 08:45:13.465161312 +0200
@@ -120,4 +120,8 @@
#define noinline
#endif

+#ifndef __always_inline
+#define __always_inline
+#endif
+
#endif /* __LINUX_COMPILER_H */
diff -u linux-2.6.7-bk9-work/include/linux/compiler-gcc3.h-o linux-2.6.7-bk9-work/include/linux/compiler-gcc3.h
--- linux-2.6.7-bk9-work/include/linux/compiler-gcc3.h-o 2004-07-08 23:58:33.000000000 +0200
+++ linux-2.6.7-bk9-work/include/linux/compiler-gcc3.h 2004-07-09 08:45:11.167510608 +0200
@@ -9,6 +9,10 @@
# define __inline __inline__ __attribute__((always_inline))
#endif

+#if __GNUC_MINOR__ >= 1
+# define __always_inline inline __attribute__((always_inline))
+#endif
+
#if __GNUC_MINOR__ > 0
# define __deprecated __attribute__((deprecated))
#endif