链接时优化 (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 http://gcc.opensuse.org/).
关于c - 支持链接时优化的技术和模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8023950/