r189369 - Warn that -O4 is the same as -O3.

Eric Christopher echristo at gmail.com
Wed Sep 11 22:38:44 PDT 2013


You missed a pretty long discussion about it... see a thread with me,
Rafael, and Shuxin (and others) in it. :)

-eric

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



More information about the cfe-commits mailing list