G++ denies to inline at -Os because "call is unlikely ...".

Sergey Organov sorganov@gmail.com
Fri Dec 4 11:25:00 GMT 2015


Hello,

I'm trying to upgrade from gcc 3.x to gcc 5.2.x for my project, and if I
use -Os optimization, I get a lot of warnings of the form:

warning: inlining failed in call to X::f(): call is unlikely and code size would grow [-Winline] 

for functions that are being happily inlined at -O2 without any
warnings.

The problem is that while the code would likely to grow because of
inlining indeed, the calls themselves are very likely, and I do want
inlining of these calls despite -Os option.

I don't want to resort to putting __attribute__((always_inline)) to all
these functions, so is there a way to force inlining in this case using
g++ command-line options without changing -Os to -O2?

I've already tried:

   --param max-inline-insns-single=1000000
   --param large-function-growth=100000
   --param inline-unit-growth=100000

but they don't help.

Alternatively, what optimization options to turn on in addition to
-O1 or -O2 to get closer to -Os?

-- Sergey.



More information about the Gcc-help mailing list