http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46228
--- Comment #11 from Jan Hubicka <hubicka at gcc dot gnu.org> 2010-11-04 17:32:32 UTC --- Created attachment 22284 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22284 Patch I am testing Hi, this patch makes size metric more realistic in two ways 1) We assumed that return statement has size of 0 while it doesn't 2) We completely ignored the static cost of offline copy of function (i.e. prologue/epilogue/alignment). Accounting those two should give GCC a little extra push to inline function whose offline copies disappears. Many cases where -Os decided to not inline was off-by-one cases in the cost metric, so this should make it slightly better. In the case of COMDATs however this still does not help, since the offline copy of function is supposed to be shared with other unit and thus not really eliminated by full inlining. Therefore I also added the trick assuming that there is only 1/8th probability of sharing comdat with someone else. It is lousy but only way to reflect reality I think. Perhaps we can do some addtional guesswork if the function is instantiation of template or so, but that would require some cooperation with the C++ FE. I added it for overnight testing for SPEC/CSiBE/C++ benchmarks on Vangelis and will give it a try building Mozilla. Tramp3d gets 50% code size reduction at -Os (and -Os is now actually smaller than -O2 and executes about 3 times slower) and I would expect improvements on C benchmarks, too. The COMDAT trick should not kick in at C code and the prologue/epilogue/return trick should just do good job. At -O2 I get 6% code size savings at tramp3d. Honza P.S. LTO can now build Mozilla, so -fwhole-program should be more useful than before ;)