Index: include/clang/Driver/CLCompatOptions.td =================================================================== --- include/clang/Driver/CLCompatOptions.td +++ include/clang/Driver/CLCompatOptions.td @@ -85,16 +85,19 @@ HelpText<"Assume thread-local variables are defined in the executable">; def _SLASH_GR : CLFlag<"GR">, HelpText<"Enable emission of RTTI data">; def _SLASH_GR_ : CLFlag<"GR-">, HelpText<"Disable emission of RTTI data">; +def _SLASH_GF : CLIgnoredFlag<"GF">, HelpText<"Enable string pooling (default)">; def _SLASH_GF_ : CLFlag<"GF-">, HelpText<"Disable string pooling">, Alias; -def _SLASH_GS : CLFlag<"GS">, HelpText<"Enable buffer security check">; +def _SLASH_GS : CLFlag<"GS">, HelpText<"Enable buffer security check (default)">; def _SLASH_GS_ : CLFlag<"GS-">, HelpText<"Disable buffer security check">; -def _SLASH_Gs : CLJoined<"Gs">, HelpText<"Set stack probe size">, - Alias; +// FIXME: Not sure /Gs really means /Gs0 (see PR39074). +def : CLFlag<"Gs">, HelpText<"Same as /Gs0">, Alias, AliasArgs<["0"]>; +def _SLASH_Gs : CLJoined<"Gs">, + HelpText<"Set stack probe size (default 4096)">, Alias; def _SLASH_Gy : CLFlag<"Gy">, HelpText<"Put each function in its own section">, Alias; def _SLASH_Gy_ : CLFlag<"Gy-">, - HelpText<"Don't put each function in its own section">, + HelpText<"Don't put each function in its own section (default)">, Alias; def _SLASH_Gw : CLFlag<"Gw">, HelpText<"Put each data item in its own section">, Alias; @@ -109,18 +112,43 @@ 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 flags, but we also provide separate +// aliased options to provide separate help messages. +def _SLASH_O : CLJoined<"O">, + HelpText<"Set multiple /O flags at once; e.g. '/O2y-' is the same as '/O2 /y-'">, + MetaVarName<"">; +// FIXME: Not sure why we have -O0 here; MSVC doesn't support that. +def : CLFlag<"O0">, Alias, HelpText<"Disable optimization">; +def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>, + HelpText<"Optimize for size (equivalent to /Og /Os /Oy /Ob2 /Gs /GF /Gy)">; +def : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>, + HelpText<"Optimize for speed (equivalent to /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy)">; +def : CLFlag<"Ob0">, Alias<_SLASH_O>, AliasArgs<["b0"]>, + HelpText<"Disable function inlining">; +def : CLFlag<"Ob1">, Alias<_SLASH_O>, AliasArgs<["b1"]>, + HelpText<"Only inline functions which are (explicitly or implicitly) marked inline">; +def : CLFlag<"Ob2">, Alias<_SLASH_O>, AliasArgs<["b2"]>, + HelpText<"Inline functions as deemed beneficial by the compiler">; +def : CLFlag<"Od">, Alias<_SLASH_O>, AliasArgs<["d"]>, + HelpText<"Disable optimization">; +def : CLFlag<"Og">, Alias<_SLASH_O>, AliasArgs<["g"]>, + HelpText<"No effect">; +def : CLFlag<"Oi">, Alias<_SLASH_O>, AliasArgs<["i"]>, + HelpText<"Enable use of builtin functions">; +def : CLFlag<"Oi-">, Alias<_SLASH_O>, AliasArgs<["i-"]>, + HelpText<"Disable use of builtin functions">; +def : CLFlag<"Os">, Alias<_SLASH_O>, AliasArgs<["s"]>, + HelpText<"Optimize for size">; +def : CLFlag<"Ot">, Alias<_SLASH_O>, AliasArgs<["t"]>, + HelpText<"Optimize for speed">; +def : CLFlag<"Ox">, Alias<_SLASH_O>, AliasArgs<["x"]>, + HelpText<"Deprecated (equivalent to /Og /Oi /Ot /Oy /Ob2); use /O2 instead">; +def : CLFlag<"Oy">, Alias<_SLASH_O>, AliasArgs<["y"]>, + HelpText<"Enable frame pointer omission (x86 only)">; +def : CLFlag<"Oy-">, Alias<_SLASH_O>, AliasArgs<["y-"]>, + HelpText<"Disable frame pointer omission (x86 only, default)">; + def _SLASH_QUESTION : CLFlag<"?">, Alias, HelpText<"Display available options">; def _SLASH_Qvec : CLFlag<"Qvec">, @@ -326,10 +354,8 @@ def _SLASH_FC : CLIgnoredFlag<"FC">; def _SLASH_Fd : CLIgnoredJoined<"Fd">; def _SLASH_FS : CLIgnoredFlag<"FS">; -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,10 +1,10 @@ -// RUN: %clang -target i386-apple-darwin9 -m32 -Xarch_i386 -O2 %s -S -### 2>&1 | FileCheck -check-prefix=O2ONCE %s -// O2ONCE: "-O2" -// O2ONCE-NOT: "-O2" +// RUN: %clang -target i386-apple-darwin9 -m32 -Xarch_i386 -O3 %s -S -### 2>&1 | FileCheck -check-prefix=O3ONCE %s +// O3ONCE: "-O3" +// O3ONCE-NOT: "-O3" -// RUN: %clang -target i386-apple-darwin9 -m64 -Xarch_i386 -O2 %s -S -### 2>&1 | FileCheck -check-prefix=O2NONE %s -// O2NONE-NOT: "-O2" -// O2NONE: argument unused during compilation: '-Xarch_i386 -O2' +// RUN: %clang -target i386-apple-darwin9 -m64 -Xarch_i386 -O3 %s -S -### 2>&1 | FileCheck -check-prefix=O3NONE %s +// O3NONE-NOT: "-O3" +// O3NONE: argument unused during compilation: '-Xarch_i386 -O3' // RUN: not %clang -target i386-apple-darwin9 -m32 -Xarch_i386 -o -Xarch_i386 -S %s -S -Xarch_i386 -o 2>&1 | FileCheck -check-prefix=INVALID %s // INVALID: error: invalid Xarch argument: '-Xarch_i386 -o'