Whole-Program Compiler Optimizations for x64
Windows Driver Kit: Kernel-Mode Driver Architecture
Whole-Program Compiler Optimizations for x64

The compiler for x64-based processors supports whole-program optimization (WPO). Essentially, this allows the compiler to view all object modules at once before generating code. This also allows the compiler to do several optimizations, such as inlining. The compiler accomplishes this by compiling source modules to a temporary intermediate language and waiting for the link phase for code generation. At that time, all modules compiled for WPO become visible to the compiler.

To use WPO, set the /GL compiler switch. This causes the compiler to generate the intermediate language object files rather than generate code for the object files. Use the /LTCG (link time-code generation) switch to invoke the linker. This indicates to the linker that code generation occurs during this phase. The linker can use WPO without the /LTCG switch, but you might experience extra performance loss during build time. For one-step compiles (builds that do not use the /c compiler switch), the linker is automatically invoked with the /LTCG switch.

You can use WPO to generate both libraries (intermediate file objects) and executable images. You do not need to compile all files with /GL for WPO to work. For example, WPO can be used with typically compiled external libraries. WPO is only performed on those files compiled with the /GL flag.

If you are going to build using WPO, the resultant libraries and objects should not be redistributed, because they have dependencies on the specific version of the compiler used.

Note that WPO builds take longer to compile and require more memory than typical builds.

The linker switches in the following table perform the indicated actions.

SwitchAction
/LTCGCauses the linker to use WPO.
/ALLOWBIND (linker)/ALLOWBIND:NO sets a bit in a DLL's header that indicates to Bind.exe that the image is not allowed to be bound.
/LARGEADDRESSAWAREInforms the linker that the application can handle addresses larger than 2 gigabytes.
/opt:lbrOptimizes away unnecessary long-branch table entries.


Send feedback on this topic
Built on August 05, 2009
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View