Skip to content

Commit 32cd703

Browse files
committed
[clang-cl] Support the /Ob3 flag
According to the docs, this was added in VS2019 and specifies more aggressive inlining than /Ob2. Let's treat it the same as /Ob2 for now.
1 parent b6b0f97 commit 32cd703

File tree

4 files changed

+6
-0
lines changed

4 files changed

+6
-0
lines changed

clang/docs/UsersManual.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4632,6 +4632,7 @@ Execute ``clang-cl /?`` to see a list of supported options:
46324632
/Ob0 Disable function inlining
46334633
/Ob1 Only inline functions which are (explicitly or implicitly) marked inline
46344634
/Ob2 Inline functions as deemed beneficial by the compiler
4635+
/Ob3 Same as /Ob2
46354636
/Od Disable optimization
46364637
/Og No effect
46374638
/Oi- Disable use of builtin functions

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8262,6 +8262,8 @@ def : CLFlag<"Ob1">, Alias<_SLASH_O>, AliasArgs<["b1"]>,
82628262
HelpText<"Only inline functions explicitly or implicitly marked inline">;
82638263
def : CLFlag<"Ob2">, Alias<_SLASH_O>, AliasArgs<["b2"]>,
82648264
HelpText<"Inline functions as deemed beneficial by the compiler">;
8265+
def : CLFlag<"Ob3">, Alias<_SLASH_O>, AliasArgs<["b3"]>,
8266+
HelpText<"Same as /Ob2">;
82658267
def : CLFlag<"Od", [CLOption, DXCOption]>, Alias<_SLASH_O>, AliasArgs<["d"]>,
82668268
HelpText<"Disable optimization">;
82678269
def : CLFlag<"Og">, Alias<_SLASH_O>, AliasArgs<["g"]>,

clang/lib/Driver/ToolChains/MSVC.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ static void TranslateOptArg(Arg *A, llvm::opt::DerivedArgList &DAL,
880880
DAL.AddFlagArg(A, Opts.getOption(options::OPT_finline_hint_functions));
881881
break;
882882
case '2':
883+
case '3':
883884
DAL.AddFlagArg(A, Opts.getOption(options::OPT_finline_functions));
884885
break;
885886
}

clang/test/Driver/cl-options.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@
163163
// Ob0: -fno-inline
164164

165165
// RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
166+
// RUN: %clang_cl /Ob3 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
166167
// RUN: %clang_cl /Odb2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
168+
// RUN: %clang_cl /Odb3 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
167169
// RUN: %clang_cl /O2 /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
168170
// Ob2-NOT: warning: argument unused during compilation: '/O2'
169171
// Ob2: -finline-functions

0 commit comments

Comments
 (0)