diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/docs/CommandGuide/clang.rst | 5 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 3 | ||||
-rw-r--r-- | clang/test/Preprocessor/init.c | 6 |
3 files changed, 13 insertions, 1 deletions
diff --git a/clang/docs/CommandGuide/clang.rst b/clang/docs/CommandGuide/clang.rst index c71544915e4..8aade1a6ab1 100644 --- a/clang/docs/CommandGuide/clang.rst +++ b/clang/docs/CommandGuide/clang.rst @@ -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 diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 86a3c87ed5c..2bdd40cc995 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -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); } diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index 61640a0fadc..d5d83da0fb3 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -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 |