title: Optimization levels in LLVM and Clang
body: <p>I am working on a project that I had been compiling with LLVM 2.6 and the llvm-gcc front end.  I'm trying to test compiling it with LLVM 3.1 and clang.  When I did this I got the following error message about -O5 optimization level:</p>
  
  <pre><code>error: invalid value '5' in '-O5'
  </code></pre>
  
  <p>However, LLVM 2.6 and llvm-gcc have worked fine with the <code>-O5</code> flag.  I saw the following documentation about the Clang optimization levels:</p>
  
  <pre><code>-O0 -O1 -O2 -Os -O3 -O4
         Specify which optimization level to use.  -O0 means "no optimization": this level compiles the
         fastest and generates the most debuggable code.  -O2 is a moderate level of optimization which
         enables most optimizations.  -Os is like -O2 with extra optimizations to reduce code size.  -O3
         is like -O2, except that it enables optimizations that take longer to perform or that may
         generate larger code (in an attempt to make the program run faster).  On supported platforms, -O4
         enables link-time optimization; object files are stored in the LLVM bitcode file format and whole
         program optimization is done at link time. -O1 is somewhere between -O0 and -O2.
  </code></pre>
  
  <p>So I'm trying to figure out what the <code>-O5</code> in the Makefile I'm working with was doing in the first place (I didn't write the Makefile).  Is this something that changed and used to be used with LLVM?  Or is it still a useful feature and I just need to activate it in some other way.</p>
  
  <p>Also in case it's useful the command I'm running that is giving the error is basically:</p>
  
  <pre><code>/bin/clang -g -c -mcmodel=medium -fstrict-aliasing -Wstrict-aliasing -O5 -emit-llvm -fkeep-inline-functions -fno-stack-protector -c -o foo.bc foo.cpp
  </code></pre>
  
  <p>Also in case it matters I am running on a Linux (Ubuntu 10.04) x86_64 system.</p>