[cfe-dev] [LLVMdev] Meaning of LLVM optimization levels

Chris Lattner clattner at apple.com
Mon Jun 17 23:17:44 PDT 2013


On Jun 6, 2013, at 1:40 PM, Renato Golin <renato.golin at linaro.org> wrote:

> Folks,
> 
> I'm trying to rationalize about optimization levels and maybe we should come up with a document like this:
> 
> http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
> 
> Though, I remember a discussion a few months ago, and some people recommended we had names, rather than numbers, to dissociate the idea that 3 is better than 2. Regardless, would be good to have some guidelines on what goes where, so we don't end up in yet another long discussion about where to put the optimization <insert-name-here>.
> 
> As far as I can get from our side is:
> 
> -O3 : throw everything and hope it sticks
> -O2 : optimized build, but should not explode in code size nor consume all resources while compiling
> -O1 : optimized debug binaries, don't change the execution order but remove dead code and stuff
> -O0 : don't touch it
> -Os : optimize, but don't run passes that could blow up code. Try to be a bit more drastic when removing code. When in doubt, prefer small, not fast code.
> -Oz : only perform optimizations that reduce code size. Don't even try to run things that could potentially increase code size.

I think that this is a pretty good codification of how things work, but we should separate out the mechanics (e.g. running passes) from the goals (don't blow up code size).  Something like this definitely should be in the Clang user docs.  The LLVM docs should have something similar but less "GCC command line option" centric.

-Chris



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130617/142e2825/attachment.html>


More information about the cfe-dev mailing list