Index: include/clang/Driver/CLCompatOptions.td =================================================================== --- include/clang/Driver/CLCompatOptions.td +++ include/clang/Driver/CLCompatOptions.td @@ -109,18 +109,25 @@ Alias; def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">, Alias; -def _SLASH_O0 : CLFlag<"O0">, Alias; -// /Oy- is handled by the /O option because /Oy- only has an effect on 32-bit. -def _SLASH_O : CLJoined<"O">, HelpText<"Optimization level">; -def _SLASH_Od : CLFlag<"Od">, HelpText<"Disable optimization">, Alias; -def _SLASH_Oi : CLFlag<"Oi">, HelpText<"Enable use of builtin functions">, - Alias; -def _SLASH_Oi_ : CLFlag<"Oi-">, HelpText<"Disable use of builtin functions">, - Alias; -def _SLASH_Os : CLFlag<"Os">, HelpText<"Optimize for size">, Alias, - AliasArgs<["s"]>; -def _SLASH_Ot : CLFlag<"Ot">, HelpText<"Optimize for speed">, Alias, - AliasArgs<["2"]>; + +// The _SLASH_O option handles all the /O variants, but we also provide separate aliased options to provide separate help messages. +def _SLASH_O : CLJoined<"O">, HelpText<"Set the optimization level">, MetaVarName<"[0|1|2|b{0123}|d|g|i[-]|s|t|x|y[-]]">; +def _SLASH_O0 : CLFlag<"O0">, Alias, HelpText<"Disable optimization">; +def _SLASH_O1 : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>, HelpText<"Optimize for small size (equivalent to /Og /Os /Oy /Ob2 /Gs /GF /Gy)">; +def _SLASH_O2 : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>, HelpText<"Optimize for maximum speed (equivalent to /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy)">; +def _SLASH_Ob0 : CLFlag<"Ob0">, Alias<_SLASH_O>, AliasArgs<["b0"]>, HelpText<"Disable inlining">; +def _SLASH_Ob1 : CLFlag<"Ob1">, Alias<_SLASH_O>, AliasArgs<["b1"]>, HelpText<"Inline functions which are (explicitly or implicitly) marked inline">; +def _SLASH_Ob2 : CLFlag<"Ob2">, Alias<_SLASH_O>, AliasArgs<["b2"]>, HelpText<"Inline suitable functions">; +def _SLASH_Od : CLFlag<"Od">, Alias, HelpText<"Disable optimization">; +def _SLASH_Og : CLFlag<"Og">, Alias<_SLASH_O>, AliasArgs<["g"]>; +def _SLASH_Oi : CLFlag<"Oi">, Alias<_SLASH_O>, AliasArgs<["i"]>, HelpText<"Optimize using builtin knowledge of functions">; +def _SLASH_Oi_ : CLFlag<"Oi-">, Alias<_SLASH_O>, AliasArgs<["i-"]>, HelpText<"Disable optimization based on builtin knowledge of functions">; +def _SLASH_Os : CLFlag<"Os">, Alias<_SLASH_O>, AliasArgs<["s"]>, HelpText<"Optimize for small size over speed">; +def _SLASH_Ot : CLFlag<"Ot">, Alias<_SLASH_O>, AliasArgs<["t"]>, HelpText<"Optimize for speed over small size">; +def _SLASH_Ox : CLFlag<"Ox">, Alias<_SLASH_O>, AliasArgs<["x"]>, HelpText<"Optimize maximum speed (equivalent to /Og /Oi /Ot /Oy /Ob2)">; +def _SLASH_Oy : CLFlag<"Oy">, Alias<_SLASH_O>, AliasArgs<["y"]>, HelpText<"Enable frame pointer omission (x86 only)">; +def _SLASH_Oy_ : CLFlag<"Oy-">, Alias<_SLASH_O>, AliasArgs<["y-"]>, HelpText<"Disable frame pointer omission (x86 only)">; + def _SLASH_QUESTION : CLFlag<"?">, Alias, HelpText<"Display available options">; def _SLASH_Qvec : CLFlag<"Qvec">, @@ -329,7 +336,6 @@ def _SLASH_GF : CLIgnoredFlag<"GF">; def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">; def _SLASH_nologo : CLIgnoredFlag<"nologo">; -def _SLASH_Og : CLIgnoredFlag<"Og">; def _SLASH_openmp_ : CLIgnoredFlag<"openmp-">; def _SLASH_permissive_ : CLIgnoredFlag<"permissive-">; def _SLASH_RTC : CLIgnoredJoined<"RTC">; Index: lib/Driver/ToolChains/MSVC.cpp =================================================================== --- lib/Driver/ToolChains/MSVC.cpp +++ lib/Driver/ToolChains/MSVC.cpp @@ -1378,6 +1378,7 @@ } break; case 'g': + A->claim(); break; case 'i': if (I + 1 != E && OptStr[I + 1] == '-') { Index: test/Driver/Xarch.c =================================================================== --- test/Driver/Xarch.c +++ test/Driver/Xarch.c @@ -1,8 +1,8 @@ -// RUN: %clang -target i386-apple-darwin9 -m32 -Xarch_i386 -O2 %s -S -### 2> %t.log -// RUN: grep ' "-O2" ' %t.log | count 1 -// RUN: %clang -target i386-apple-darwin9 -m64 -Xarch_i386 -O2 %s -S -### 2> %t.log -// RUN: not grep ' "-O2" ' %t.log -// RUN: grep "argument unused during compilation: '-Xarch_i386 -O2'" %t.log +// RUN: %clang -target i386-apple-darwin9 -m32 -Xarch_i386 -O3 %s -S -### 2> %t.log +// RUN: grep ' "-O3" ' %t.log | count 1 +// RUN: %clang -target i386-apple-darwin9 -m64 -Xarch_i386 -O3 %s -S -### 2> %t.log +// RUN: not grep ' "-O3" ' %t.log +// RUN: grep "argument unused during compilation: '-Xarch_i386 -O3'" %t.log // RUN: not %clang -target i386-apple-darwin9 -m32 -Xarch_i386 -o -Xarch_i386 -S %s -S -Xarch_i386 -o 2> %t.log // RUN: grep "error: invalid Xarch argument: '-Xarch_i386 -o'" %t.log | count 2 // RUN: grep "error: invalid Xarch argument: '-Xarch_i386 -S'" %t.log