inlining questions

inlining questions

I'm having some problems with inlining using the Windows C++ Compiler (W_CC_PC_8.0.048_PE051.1).

The first problem is that I can't compile one of my cpp files with /Ob2 (any suitable) because the compiler hits the 2 Gb virtual memory limit in Windows. This memory usage is rather surprising considering that the entire exe (with /Ob1) is only 2.9 Mb. The code does make extremely heavy use of templates, especially expression templates, and the /Ob1 obj file for the problem code is 24 Mb. I'm not trying to do any cross-file optimization (/Qipo). I am using /Og and I've tried /O2 and /O3.

The other problem is that the executable produced with /Ob1 is quite slow. Experimenting with a simplified version of the code shows a factor of 5 difference between /Ob1 and /Ob2 even though all the important functions have been declared inline.

Examination of a small test case shows that /Ob1 is not inlining functions that have been explicitly declared inline and not inlining functions that are defined within the class declaration and are therefore implicitly inline, as I understand it.

The documentation for /Ob1 says ... "1: Enables (default) inlining of functions declared with the __inline keyword. Also enables inlining according to the C++ language." which is not consistent with what I'm seeing. It may be that /Ob1 actually requires "__inline".

Does anyone have any suggestions on how to reduce the memory usage with /Ob2 or get /Ob1 to perform better?


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Any news on this topic?
I have the same impression, that inline member functions do not always get inlined.
The performance compared to the g++ compiler (tried 2.96 and 3.3) is therefore reduced by a factor of 3!

I also tried profile directed optimisation (-prof_gen, -prof_use) with no improvement at all.

Leave a Comment

Please sign in to add a comment. Not a member? Join today