3 ms·
gcc, clang, and Intel all both support this feature, calling it "Link-Time Optimization".[1,2,3] This allows them to inline virtual functions they can resolve,
by stochastic_monk 9y ago
gcc, clang, and Intel all both support this feature, calling it "Link-Time Optimization".[1,2,3] This allows them to inline virtual functions they can resolve, non-inline functions which are not visible to external units, as well as perform combinatorial optimizations by being able to "see" more of the code together at once.
In addition to binary size (which I've never worried about too much, as I mostly write code for scientific computing), it has often improved runtime significantly. The only other specific optimization besides -flto that I have had very real speedups from (not counting -O[23] or -Ofast) has been -funroll-loops. I use it on nearly every project. (And, to be honest, I haven't seen a big slowdown in compile time over just -O3, though I think a lot of my costs there are from templates.)
[1] https://gcc.gnu.org/wiki/LinkTimeOptimization https://gcc.gnu.org/wiki/LinkTimeOptimization
[2] https://llvm.org/docs/LinkTimeOptimization.html https://llvm.org/docs/LinkTimeOptimization.html
[3] https://software.intel.com/en-us/node/522667 https://software.intel.com/en-us/node/522667
- vvanders 9y agoYup, pretty sure LTO and LTCG are pretty close these days, if not the same thing.
- throwaway613834 9y agoConfused, was there ever a difference?
- vvanders 9y agoLTCG is MSVC specific, given that they're different compilers I can't say if the optimizations were identical.
- throwaway613834 9y agoOh, I thought you meant they used to be different features, not that they used to be different implementations of the same concept.