[PATCH] Using an invalid -O falls back on -O3 instead of an error

Renato Golin renato.golin at linaro.org
Fri Nov 8 11:19:26 PST 2013


Hi Sylvestre,

I agree with this change, too many people still believe that -O20 will give
them 7x better code than -O3... sigh...

Some comments below:

On 8 November 2013 06:05, Sylvestre Ledru <sylvestre at debian.org> wrote:

>    unsigned OptLevel = getOptimizationLevel(Args, IK, Diags);
>    if (OptLevel > 3) {
> -    Diags.Report(diag::err_drv_invalid_value)
> -      << Args.getLastArg(OPT_O)->getAsString(Args) << OptLevel;
> -    OptLevel = 3;
> -    Success = false;
> +    unsigned DefaultOptLevel = 3;
> +    Diags.Report(diag::warn_drv_invalid_value)
> +        << Args.getLastArg(OPT_O)->getAsString(Args) << OptLevel <<
> DefaultOptLevel;
> +    OptLevel = DefaultOptLevel;
>    }
>    Opts.OptimizationLevel = OptLevel;
>

This seems slightly redundant. Either you use literal 3 all over, or set
the DefaultOptLevel on a higher place. Also, this is not the "default"
level, but the fall-back level for high levels, maybe a better word would
be "MaxOptLevel", if there isn't one already (I don't know).

If there isn't, than maybe you could create a MaxOptLevel on a higher level
and change all comparisons "OptLevel > 3" for "OptLevel > MaxOptLevel".

cheers,
--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131108/3d61046d/attachment.html>


More information about the cfe-commits mailing list