sudeep dasan
sudeep dasan

Reputation: 81

gcc -finline-functions option

I have a question regarding the -finline-function options

We are testing whether the function which we have implemented is getting successfully inlined. Here are the observation

  1. The functions are getting inlined for -01,-O2 and -O3 optimization levels.
  2. The functions are not getting inlined for optimization level -O0, which is expected.

When we tried compiling using -O0 and -finline-functions together, we still observed that the functions are not getting inlined. we even tried for a very simple method(one line return statement) and observed the same result.

So it seems that usage of -finline-functions flag along with -O0 is redundant(It will not make functions inline). I am still searching if this behavior is documented somewhere in gcc/g++ manual. Please let us know if anyone has exact idea about how g++ works specify -finline-functions and -O0 together.

Regards

Upvotes: 0

Views: 4838

Answers (2)

Shouguo
Shouguo

Reputation: 31

define your function like this inline void foo (const char) __attribute__((always_inline));

From website (https://gcc.gnu.org/onlinedocs/gcc/Inline.html)

Upvotes: 0

servn
servn

Reputation: 3069

From the gcc manual ( http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html ):

Most optimizations are only enabled if an -O level is set on the command line. Otherwise they are disabled, even if individual optimization flags are specified.

Upvotes: 4

Related Questions