Author: sylvestre
Date: Fri Nov 11 11:29:56 2016
New Revision: 286602

URL: http://llvm.org/viewvc/llvm-project?rev=286602&view=rev
Log:
Add a new optimization option -Og 

Summary:
Just like gcc, we should have the -Og option as more and more software are 
using it:
https://llvm.org/bugs/show_bug.cgi?id=20765

Reviewers: echristo, dberlin, dblaikie, keith.walker.arm, rengolin

Subscribers: aprantl, friss, mehdi_amini, RKSimon, probinson, majnemer, 
cfe-commits

Differential Revision: https://reviews.llvm.org/D24998

Modified:
    cfe/trunk/docs/CommandGuide/clang.rst
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
    cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/docs/CommandGuide/clang.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=286602&r1=286601&r2=286602&view=diff
==============================================================================
--- cfe/trunk/docs/CommandGuide/clang.rst (original)
+++ cfe/trunk/docs/CommandGuide/clang.rst Fri Nov 11 11:29:56 2016
@@ -226,7 +226,7 @@ number of cross compilers, or may only s
 Code Generation Options
 ~~~~~~~~~~~~~~~~~~~~~~~
 
-.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -O, -O4
+.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -Og, -O, -O4
 
   Specify which optimization level to use:
 
@@ -252,6 +252,9 @@ Code Generation Options
     :option:`-Oz` Like :option:`-Os` (and thus :option:`-O2`), but reduces code
     size further.
 
+    :option:`-Og` Like :option:`-O1`. In future versions, this option might 
+    disable different optimizations in order to improve debuggability.
+
     :option:`-O` Equivalent to :option:`-O2`.
 
     :option:`-O4` and higher

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=286602&r1=286601&r2=286602&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Nov 11 11:29:56 2016
@@ -98,6 +98,9 @@ static unsigned getOptimizationLevel(Arg
     if (S == "s" || S == "z" || S.empty())
       return 2;
 
+    if (S == "g")
+      return 1;
+
     return getLastArgIntValue(Args, OPT_O, DefaultOpt, Diags);
   }
 

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=286602&r1=286601&r2=286602&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Fri Nov 11 11:29:56 2016
@@ -205,6 +205,12 @@
 // O1:#define __OPTIMIZE__ 1
 //
 //
+// RUN: %clang_cc1 -Og -E -dM < /dev/null | FileCheck -match-full-lines 
-check-prefix Og %s
+//
+// Og-NOT:#define __OPTIMIZE_SIZE__
+// Og  :#define __OPTIMIZE__ 1
+//
+//
 // RUN: %clang_cc1 -Os -E -dM < /dev/null | FileCheck -match-full-lines 
-check-prefix Os %s
 //
 // Os:#define __OPTIMIZE_SIZE__ 1


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to