4

There some very good descriptions on SO, as well as all over the web, about how LLVM optimizes code. But these fail to answer my specific question.

In Xcode, there are various options for code optimization in the project and target settings. I understand the need for no optimization during development, but why would one choose anything other than Fastest,Smallest[-Os] when compiling a release build.

4

1 回答 1

4

在大多数情况下,-Os 是一个不错的选择。它很好地结合了空间优化和速度优化。

但是,其他选项确实有一些吸引力:

  • -O/-O1:“我希望能够多一点调试优化代码的能力”
  • -O2:(好吧,老实说,我不确定为什么会选择 -O2 而不是 -Os。也许如果特定的代码大小优化 -Os 确实会严重损害性能?)
  • -O3:“这部分代码需要快速,并且对激进的内联和循环展开响应足够好,以抵消代码大小的损失”
于 2013-01-31T17:53:29.603 回答