<div dir="ltr">Hi Rafael,<div><br></div><div>This is a behavior change, -O4 used to imply LTO. Maybe I missed a discussion about changing this, but this is unexpected to me.</div><div><br></div><div> - Daniel</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Aug 27, 2013 at 9:58 AM, Rafael Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: rafael<br>
Date: Tue Aug 27 11:58:15 2013<br>
New Revision: 189369<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=189369&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=189369&view=rev</a><br>
Log:<br>
Warn that -O4 is the same as -O3.<br>
<br>
We error on -O5 and higher. While it is tempting to do the same for -O4, I<br>
agree with Jordan Rose: we should warn for a release at least first.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td<br>
cfe/trunk/include/clang/Driver/Options.td<br>
cfe/trunk/lib/Driver/Tools.cpp<br>
cfe/trunk/test/Driver/clang_f_opts.c<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=189369&r1=189368&r2=189369&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=189369&r1=189368&r2=189369&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Aug 27 11:58:15 2013<br>
@@ -112,6 +112,7 @@ def err_drv_unknown_objc_runtime : Error<br>
def err_drv_emit_llvm_link : Error<<br>
"-emit-llvm cannot be used when linking">;<br>
<br>
+def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup<Deprecated>;<br>
def warn_c_kext : Warning<<br>
"ignoring -fapple-kext which is valid for C++ and Objective-C++ only">;<br>
def warn_drv_input_file_unused : Warning<<br>
<br>
Modified: cfe/trunk/include/clang/Driver/Options.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=189369&r1=189368&r2=189369&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=189369&r1=189368&r2=189369&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Driver/Options.td (original)<br>
+++ cfe/trunk/include/clang/Driver/Options.td Tue Aug 27 11:58:15 2013<br>
@@ -214,13 +214,13 @@ def MT : JoinedOrSeparate<["-"], "MT">,<br>
def Mach : Flag<["-"], "Mach">;<br>
def M : Flag<["-"], "M">, Group<M_Group>;<br>
def O0 : Flag<["-"], "O0">, Group<O_Group>, Flags<[CC1Option]>;<br>
+def O4 : Flag<["-"], "O4">, Group<O_Group>, Flags<[CC1Option]>;<br>
def ObjCXX : Flag<["-"], "ObjC++">, Flags<[DriverOption]>,<br>
HelpText<"Treat source input files as Objective-C++ inputs">;<br>
def ObjC : Flag<["-"], "ObjC">, Flags<[DriverOption]>,<br>
HelpText<"Treat source input files as Objective-C inputs">;<br>
def O : Joined<["-"], "O">, Group<O_Group>, Flags<[CC1Option]>;<br>
def O_flag : Flag<["-"], "O">, Flags<[CC1Option]>, Alias<O>, AliasArgs<["2"]>;<br>
-def O4 : Flag<["-"], "O4">, Alias<O>, AliasArgs<["3"]>;<br>
def Ofast : Joined<["-"], "Ofast">, Group<O_Group>, Flags<[CC1Option]>;<br>
def P : Flag<["-"], "P">, Flags<[CC1Option]>,<br>
HelpText<"Disable linemarker output in -E mode">;<br>
<br>
Modified: cfe/trunk/lib/Driver/Tools.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=189369&r1=189368&r2=189369&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=189369&r1=189368&r2=189369&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Tools.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Aug 27 11:58:15 2013<br>
@@ -1863,7 +1863,8 @@ static bool isOptimizationLevelFast(cons<br>
/// \brief Vectorize at all optimization levels greater than 1 except for -Oz.<br>
static bool shouldEnableVectorizerAtOLevel(const ArgList &Args) {<br>
if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {<br>
- if (A->getOption().matches(options::OPT_Ofast))<br>
+ if (A->getOption().matches(options::OPT_O4) ||<br>
+ A->getOption().matches(options::OPT_Ofast))<br>
return true;<br>
<br>
if (A->getOption().matches(options::OPT_O0))<br>
@@ -2622,8 +2623,15 @@ void Clang::ConstructJob(Compilation &C,<br>
// preprocessed inputs and configure concludes that -fPIC is not supported.<br>
Args.ClaimAllArgs(options::OPT_D);<br>
<br>
- if (Arg *A = Args.getLastArg(options::OPT_O_Group))<br>
- A->render(Args, CmdArgs);<br>
+ // Manually translate -O4 to -O3; let clang reject others.<br>
+ if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {<br>
+ if (A->getOption().matches(options::OPT_O4)) {<br>
+ CmdArgs.push_back("-O3");<br>
+ D.Diag(diag::warn_O4_is_O3);<br>
+ } else {<br>
+ A->render(Args, CmdArgs);<br>
+ }<br>
+ }<br>
<br>
// Don't warn about unused -flto. This can happen when we're preprocessing or<br>
// precompiling.<br>
<br>
Modified: cfe/trunk/test/Driver/clang_f_opts.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=189369&r1=189368&r2=189369&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=189369&r1=189368&r2=189369&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/clang_f_opts.c (original)<br>
+++ cfe/trunk/test/Driver/clang_f_opts.c Tue Aug 27 11:58:15 2013<br>
@@ -97,4 +97,5 @@<br>
// CHECK-NO-M-PASCAL-STRINGS-NOT: "-fpascal-strings"<br>
<br>
// RUN: %clang -### -S -O4 %s 2>&1 | FileCheck -check-prefix=CHECK-MAX-O %s<br>
+// CHECK-MAX-O: warning: -O4 is equivalent to -O3<br>
// CHECK-MAX-O: -O3<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>