Re: GCC 3.4 and broken inlining.

From: Andi Kleen
Date: Fri Jul 09 2004 - 23:51:46 EST


On Sat, Jul 10, 2004 at 12:17:55AM +0200, Adrian Bunk wrote:
> On Fri, Jul 09, 2004 at 11:54:15PM +0200, Andi Kleen wrote:
> > > Runtime errors caused with gcc 3.4 are IMHO much worse than such a small
> > > improvement or three dozen compile errors with gcc 3.4 .
> >
> > What runtime errors?
> >
> > Actually requiring inlining is extremly rare and such functions should
> > get that an explicit always inline just for documentation purposes.
> > (another issue is not optimized away checks, but that shows at link time)
>
> First of all, your proposed patch seems to be broken WRT gcc < 3.1 .

The latest version does fallback #define __always_inline inline
That was indeed broken in the original patch.

>
> > In the x86-64 case it was vsyscalls, in Nigel's case it was swsusp.
> > Both are quite exceptional in what they do.
> >
> > > Wouldn't it be a better solution if you would audit the existing inlines
> > > in the kernel for abuse of inline and fix those instead?
> >
> > I don't see any point in going through ~1.2MLOC of code by hand
> > when a compiler can do it for me.
>
> How can a compiler decide whether an "inline" was for a possible small
> speed benefit or whether it's required for correct working?

It can't, but the 0.001% of needed for inlines that are required
for correctness should be always marked __always_inline
just for documentation alone.
You probably don't realize how special a case this is.

> And I'm not that happy with the fact that gcc 3.3 and gcc 3.4 will
> produce significantly different code for the same file. Besides from the
> 3 dozen compile errors I'm currently sorting out, gcc 3.3 and 3.4 should
> behave similar with __attribute__((always_inline)).

They are different compiler versiopns, they generate different code.

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