MSDN original:
Link-Time Code Generation
The key:
C program normal code generation includes three steps:
1. The front, C1, read source code, generate symbolic tables, analyze source code, check the correctness of syntax, generate some intermediate code (IL). Call the backend.
2. The rear end, C2, code generator, read IL, generate specific code for the CPU, code optimization, generate an OBJ file including actual code and data.
3. Link, Linker, read all OBJ files and lib files, build all code and data synthesize to the final .exe executable.
LTCG - LINK-TIME CODE Generation Link Time Code Generation
1. The front end C1 generates the IL OBJ file. Do not adjust C2.
2. Linker reads all IL OBJ files and lib files, calls C2, plug all IL code to C2 to generate the final actual code.
Benefits: Because C2 can get all the code, it can make better code optimization, better inline, interline, and TLS optimization.
How to open LTCG
1. In the VC.NET IDE, the Whole Program Optimization is set to YES.
2. Command line parameters, compiler Use / GL, use parameters / ltcg when link