/GL (Whole Program Optimization)
For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.
Enables whole program optimization.
Whole program optimization allows the compiler to perform optimizations with information on all modules in the program. Without whole program optimization, optimizations are performed on a per module (compiland) basis.
Whole program optimization is off by default and must be explicitly enabled. However, it is also possible to explicitly disable it with /GL-.
With information on all modules, the compiler can:
Optimize the use of registers across function boundaries.
Do a better job of tracking modifications to global data, allowing a reduction in the number of loads and stores.
Do a better job of tracking the possible set of items modified by a pointer dereference, reducing the numbers of loads and stores.
Inline a function in a module even when the function is defined in another module.
If you compile your program with /GL and /c, you should use the /LTCG linker option to create the output file.
/ZI cannot be used with /GL
The format of files produced with /GL in the current version may not be readable by subsequent versions of Visual C++. You should not ship a .lib file comprised of .obj files that were produced with /GL unless you are willing to ship copies of the .lib file for all versions of Visual C++ you expect your users to use, now and in the future.
.obj files produced with /GL and precompiled header files should not be used to build a .lib file unless the .lib file will be linked on the same machine that produced the /GL .obj file. Information from the .obj file's precompiled header file will be needed at link time.
For more information on the optimizations available with and the limitations of whole program optimization, see /LTCG. /GL also makes profile guided optimization available; see /LTCG. When compiling for profile guided optimizations and if you want function ordering from your profile guided optimizations, you must compile with /Gy or a compiler option that implies /Gy.
- See /LTCG (Link-time Code Generation) for information on how to specify /GL in the development environment.