r194403 - Using an invalid -O falls back on -O3 instead of an error

Chandler Carruth chandlerc at google.com
Mon Nov 11 11:58:16 PST 2013


On Mon, Nov 11, 2013 at 11:54 AM, Arthur O'Dwyer
<arthur.j.odwyer at gmail.com>wrote:

> > My preference would be to have '-O' be the fallback, and that in turn be
> > equivalent to '-O2' which is often viewed as a reasonable default level
> of
> > optimization.
>
> Note that the commit message is no longer 100% non-misleading. The
> message actually given by the code is "optimization level '-O20' is
> unsupported; using '-O3' instead."
>
> The English semantics aren't "oh no, we don't know the user's intent,
> let's do something sensible instead." The English semantics are more
> like "aha, the user explicitly requested CRAZY HIGH levels of
> optimization; let's give him the highest level we currently support."
>
> Existing projects use things like -O99 for this purpose.
>
> You would probably agree that it doesn't make sense to have -O4
> perform fewer optimizations than -O3, right?  That's what would happen
> if you made -O4 (-O5, -O99) equivalent to -O2.  (Also what Hal said.
> :))


Actually, no, I disagree with your conclusions.

I think the far and away most likely reason for a number greater than 3 is
using a numbering system from a compiler other than GCC. I have no idea
what 4 or 5 map to for those. Maybe they map to something like -O3, maybe
not.

I think assuming that these optimizations are ordered in some way based on
"fast" is wrong. For *many* C++ codebases -O2 produces consistently higher
quality code than -O3.

If we're going to *do* something when we do not understand the specific
nature of the user's request, I would like us to do the most generic thing
with the fewest assumptions. All we know is that the user wanted *some*
optimization, not how much. Let's pick our default for "some" optimization.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131111/082cbb08/attachment.html>


More information about the cfe-commits mailing list