Whole Program Optimization


  • I'm using VS2015 to build a C++ program. I'm a little confused as to why there are 2 place in the project configuration that control settings called "Whole Program Optimization".

    It is found at Configuration Properties, General, Whole Program Optimization. The choices here look like the same choices that appear under Configuration Properties, Linker, Optimization, Link Time Code Generation.

    It is also found at Configuration Properties, C/C++, Optimization, Whole Program Optimization, but the choices here are /GL yes or no. 

    Why are there 2 places to select Link Time Code Generation, and why are there 2 places labeled Whole Program Optimization?

    What I want is to give the compiler the ability to basically inline small functions that are not necessarily defined in the same source file as where they are called.  It seems I should be able to do that by compiling with /GL and linking with /LTCG. But then what is the purpose of the setting under Configuration Properties, General?

    Friday, February 12, 2016 12:36 AM


  • Hi Edgar Gilbert,

    I think you could get useful information from this thread:

    What's C++ optimization & Whole program optimizatoin in visual studio

    The main contents:

    Whole-program optimization is one aspect of cross-module optimization. This is also called link-time optimization in the context of C and C++, due to those languages' compilation models.

    Basically, imagine that the entire source code of your program was pasted into one single file, source and header and library files, everything. In that hyptothetical case, the compiler would have a lot of additional opportunities for optimization: inlining, dead-code removal, deduplication, etc.

    Cross-module optimization refers to any technique that attempts to allow such optimizations even within the traditional one-TU-at-a-time compilation that is customary to C and C++ compilers. Typically, this involves adding extra information (possibly even the entire parsed source content) into the individual object files and allowing the linker to perform certain compilation tasks once it sees all the ingredient object files for an application.

    It shared us the differences between the C++ Optimization and the Whole Program Optimization under "General" option. I think it would be helpful for us to understanding two "Whole Program Optimization" settings.



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 16, 2016 6:16 AM