work around gcc-3.x inlining bugs
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 1 line · Andrew Morton
This patch:
[...]
I submitted a similar patch (using -include) it to Linus some time ago. It's even required to work around gcc 3.3 inlining bugs. Unfortunately he didn't like it and prefered __force_inline to be added to the places that really rely on inline.
I experimented with -finline-limit=<huge number> to get it to obey inline, but that doesn't fully work. The only way to get it to work in 3.2 and 3.3 is to specify various long and weird --param arguments. In 3.0 the only way is to change the values in the compiler source and recompile.
So doing it with always_inline is much less ugly and also less compiler version dependent.
I always add them currently by hand to linux/brlock.h to get 2.5 to compile with gcc 3.3 on x86-64.
I think it is the right thing to do. In kernel land when we say inline we mean inline. Don't expect the compiler to second guess that, especially since it doesn't seem to be very good at that.
There was also talk on the gcc mailing list to add an -fobey-inline switch, but nothing got out of it. And it would be 3.3+ only anwyays.
I didn't see a 64K shrink however on x86-64, but I guess that's because it has a much cleaner uaccess.h ;) For i386 it is a nice bonus.
-Andi
Followup to: <[email protected]> By author: Andi Kleen <[email protected]> In newsgroup: linux.dev.kernel
Quoted 6 lines
I submitted a similar patch (using -include) it to Linus some time ago. It's even required to work around gcc 3.3 inlining bugs. Unfortunately he didn't like it and prefered
__force_inlineto be added to the places that really rely on inline.
I would like to suggest that always_inline is defined as "extern __inline__" plus whatever the particular compiler needs, and that plain inline is redefined as "static __inline__" or whatever.
-hpa
Signature · 3 lines
<[email protected]> at work, <[email protected]> in private! "Unix gives you enough rope to shoot yourself in the foot." Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
Hi Andi,
Quoted 9 lines · Andi Kleen
Quoted 1 line · Andrew Morton
This patch:
[...]
I experimented with -finline-limit=<huge number> to get it to obey inline, but that doesn't fully work. The only way to get it to work in 3.2 and 3.3 is to specify various long and weird --param arguments. In 3.0 the only way is to change the values in the compiler source and recompile.
--param max-inline-insns-single
The fact that this parameter does not get initialized by using -finline-limit is a bug. A fix for this has already gone into CVS HEAD (3.4) and is pending for 3.3.
[... ]
Quoted 3 lines
I think it is the right thing to do. In kernel land when we say inline we mean inline. Don't expect the compiler to second guess that, especially since it doesn't seem to be very good at that.
The compiler solely judges by the size of the function to be inlined, no magic involved.
There are two reasons, why this may not be what you expect:
- The allowable size can get smaller if in the function from that you're calling and the one above and ... were already inlined. At some moment this recursive inlining has to be stopped to not results in excessive compile time resource requirements
- When calculating the size of a function, the compiler counts tree tokens, each estimated to yield 10 RTL instructions. It does unfortunately not take into account code that will be eliminated by optimization (constant propagation, dead code elimination, ...) nor does it have a very good idea about the size of inline assembly.
Regards,
Signature · 3 lines
Kurt Garloff <[email protected]> Eindhoven, NL GPG key: See mail header, key servers SuSE Labs SuSE Linux AG, Nuernberg, DE SCSI, Security
Hi,
Quoted 3 lines · Kurt Garloff
The fact that this parameter does not get initialized by using -finline-limit is a bug. A fix for this has already gone into CVS HEAD (3.4) and is pending for 3.3.
Patch has been applied to 3.3 as well now.
Thanks to Geoff Keating and Dale Johannesen.
Regards,
Signature · 3 lines
Kurt Garloff <[email protected]> Eindhoven, NL GPG key: See mail header, key servers SuSE Labs (Head) SuSE Linux AG, Nuernberg, DE SCSI, Security