r179216 - [driver] Add a -Ofast option, which enables -O3, -ffast-math, and

Chad Rosier mcrosier at apple.com
Wed Apr 10 14:26:02 PDT 2013


Author: mcrosier
Date: Wed Apr 10 16:26:02 2013
New Revision: 179216

URL: http://llvm.org/viewvc/llvm-project?rev=179216&view=rev
Log:
[driver] Add a -Ofast option, which enables -O3, -ffast-math, and
-fstrict-aliasing.
rdar://13622687

Modified:
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=179216&r1=179215&r2=179216&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Apr 10 16:26:02 2013
@@ -181,6 +181,7 @@ def ObjCXX : Flag<["-"], "ObjC++">, Flag
 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 Ofast : Joined<["-"], "Ofast">, Group<O_Group>, Flags<[CC1Option]>;
 def P : Flag<["-"], "P">, Flags<[CC1Option]>,
   HelpText<"Disable linemarker output in -E mode">;
 def Qn : Flag<["-"], "Qn">;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=179216&r1=179215&r2=179216&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Apr 10 16:26:02 2013
@@ -68,6 +68,9 @@ static unsigned getOptimizationLevel(Arg
     if (A->getOption().matches(options::OPT_O0))
       return 0;
 
+    if (A->getOption().matches(options::OPT_Ofast))
+      return 3;
+
     assert (A->getOption().matches(options::OPT_O));
 
     StringRef S(A->getValue());
@@ -97,6 +100,13 @@ static unsigned getOptimizationLevelSize
   return 0;
 }
 
+static bool isOptimizationLevelFast(ArgList &Args) {
+  if (Arg *A = Args.getLastArg(options::OPT_O_Group))
+    if (A->getOption().matches(options::OPT_Ofast))
+      return true;
+  return false;
+}
+
 static void addWarningArgs(ArgList &Args, std::vector<std::string> &Warnings) {
   for (arg_iterator I = Args.filtered_begin(OPT_W_Group),
          E = Args.filtered_end(); I != E; ++I) {
@@ -324,7 +334,8 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
   Opts.UseRegisterSizedBitfieldAccess = Args.hasArg(
     OPT_fuse_register_sized_bitfield_access);
-  Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing);
+  Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing) ||
+    isOptimizationLevelFast(Args);
   Opts.StructPathTBAA = Args.hasArg(OPT_struct_path_tbaa);
   Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
   Opts.MergeAllConstants = !Args.hasArg(OPT_fno_merge_all_constants);
@@ -1302,7 +1313,8 @@ static void ParseLangArgs(LangOptions &O
   // inlining enabled.
   Opts.NoInlineDefine = !Opt || Args.hasArg(OPT_fno_inline);
 
-  Opts.FastMath = Args.hasArg(OPT_ffast_math);
+  Opts.FastMath = Args.hasArg(OPT_ffast_math) ||
+    isOptimizationLevelFast(Args);
   Opts.FiniteMathOnly = Args.hasArg(OPT_ffinite_math_only);
 
   Opts.RetainCommentsFromSystemHeaders =





More information about the cfe-commits mailing list