With whole-program-optimization turned on, is inlining affected by where a method is implemented?

426 Views Asked by At

With whole-program (a.k.a link-time) optimization turned on, is inlining affected by where a method is implemented?

Without whole-program-optimization turned on, methods which are publicly declared in a header but implemented in the matching cpp obviously can't be inlined during the compilation of a different translation unit (a different cpp which includes the above header). So if you want the method to be inline-able, it must be implemented in the exporting header.

With whole-program-optimization, does it make any difference, inlining-wise, whether the method is implemented in the header or not? That is, is it possible/likely for the compiler to miss an opportunity to inline a method implemented in a cpp, which it would not miss had the method been implemented in the header instead?

I'm specifically interested in the answer for Apple's Clang (-flto flag) and for Visual Studio (/GL flag).

0

There are 0 best solutions below