]> granicus.if.org Git - clang/commitdiff
Add a new optimization option -Og
authorSylvestre Ledru <sylvestre@debian.org>
Fri, 11 Nov 2016 17:29:56 +0000 (17:29 +0000)
committerSylvestre Ledru <sylvestre@debian.org>
Fri, 11 Nov 2016 17:29:56 +0000 (17:29 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286602 91177308-0d34-0410-b5e6-96231b3b80d8

docs/CommandGuide/clang.rst
lib/Frontend/CompilerInvocation.cpp
test/Preprocessor/init.c

index c71544915e4295991ef38844a95274c657846846..8aade1a6ab1e4dc5b5d99b0dcc0973c08719970d 100644 (file)
@@ -226,7 +226,7 @@ number of cross compilers, or may only support a native target.
 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
index 86a3c87ed5c175d36dd9492151a861f771cb2449..2bdd40cc99544ae7ce52a7551fcf7f8ee0df82aa 100644 (file)
@@ -98,6 +98,9 @@ static unsigned getOptimizationLevel(ArgList &Args, InputKind IK,
     if (S == "s" || S == "z" || S.empty())
       return 2;
 
+    if (S == "g")
+      return 1;
+
     return getLastArgIntValue(Args, OPT_O, DefaultOpt, Diags);
   }
 
index 61640a0fadcac80d0915cc51e45b574ff87c8fc5..d5d83da0fb350dc9d4f6dc447e7abccc7769a6fc 100644 (file)
 // 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