启用链接时优化的技术和模式?

链路时间优化(LTO)(也称为统一构建)包含在GCC 4.5或更高版本中,其他编译器具有类似的优化通道.这不会使某些代码模式比以前更可行吗?

例如,为了获得最佳性能,C代码的“模块”通常需要暴露其内容. LTO是否过时了?现在有哪些代码模式可行,而不是之前?

最佳答案 我认为LTO只是一种优化,但不一定能消除对任何模块的实施文档(“暴露内容”)的需求.已经为此编写了整个语言;我不认为C很快就会将这种需求从中删除,或者也许永远不会.

the description of the LTO feature in gcc开始:

Link Time Optimization (LTO) gives GCC the capability of dumping its
internal representation (GIMPLE) to disk, so that all the different
compilation units that make up a single executable can be optimized as
a single module. This expands the scope of inter-procedural
optimizations to encompass the whole program (or, rather, everything
that is visible at link time).

From the announcement of LTO’s inclusion into gcc

The result should, in principle, execute faster but our IPA cost
models are still not tweaked for LTO. We’ve seen speedups as well as
slowdowns in benchmarks (see the LTO testers at
07002).

点赞