Index: cfe/trunk/include/clang/Driver/CLCompatOptions.td =================================================================== --- cfe/trunk/include/clang/Driver/CLCompatOptions.td +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td @@ -102,6 +102,8 @@ def _SLASH_O : CLJoined<"O">, HelpText<"Optimization level">; def _SLASH_Ob0 : CLFlag<"Ob0">, HelpText<"Disable inlining">, Alias; +def _SLASH_Ob2 : CLFlag<"Ob2">, HelpText<"Enable inlining">, + Alias; def _SLASH_Od : CLFlag<"Od">, HelpText<"Disable optimization">, Alias; def _SLASH_Oi : CLFlag<"Oi">, HelpText<"Enable use of builtin functions">, Alias; @@ -293,7 +295,6 @@ def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">; def _SLASH_nologo : CLIgnoredFlag<"nologo">; def _SLASH_Ob1 : CLIgnoredFlag<"Ob1">; -def _SLASH_Ob2 : CLIgnoredFlag<"Ob2">; def _SLASH_Og : CLIgnoredFlag<"Og">; def _SLASH_openmp_ : CLIgnoredFlag<"openmp-">; def _SLASH_RTC : CLIgnoredJoined<"RTC">; Index: cfe/trunk/include/clang/Driver/Options.td =================================================================== --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -741,7 +741,7 @@ def fheinous_gnu_extensions : Flag<["-"], "fheinous-gnu-extensions">, Flags<[CC1Option]>; def filelist : Separate<["-"], "filelist">, Flags<[LinkerInput]>; def : Flag<["-"], "findirect-virtual-calls">, Alias; -def finline_functions : Flag<["-"], "finline-functions">, Group; +def finline_functions : Flag<["-"], "finline-functions">, Group, Flags<[CC1Option]>; def finline : Flag<["-"], "finline">, Group; def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group; def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group; Index: cfe/trunk/lib/Driver/Tools.cpp =================================================================== --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/lib/Driver/Tools.cpp @@ -5332,8 +5332,9 @@ if (Args.hasArg(options::OPT_fno_inline)) CmdArgs.push_back("-fno-inline"); - if (Args.hasArg(options::OPT_fno_inline_functions)) - CmdArgs.push_back("-fno-inline-functions"); + if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions, + options::OPT_fno_inline_functions)) + InlineArg->render(Args, CmdArgs); ObjCRuntime objcRuntime = AddObjCRuntimeArgs(Args, CmdArgs, rewriteKind); Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp =================================================================== --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp @@ -441,8 +441,12 @@ : CodeGenOptions::OnlyAlwaysInlining); // -fno-inline-functions overrides OptimizationLevel > 1. Opts.NoInline = Args.hasArg(OPT_fno_inline); - Opts.setInlining(Args.hasArg(OPT_fno_inline_functions) ? - CodeGenOptions::OnlyAlwaysInlining : Opts.getInlining()); + if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions, + options::OPT_fno_inline_functions)) { + Opts.setInlining( + InlineArg->getOption().matches(options::OPT_finline_functions) ? + CodeGenOptions::NormalInlining : CodeGenOptions::OnlyAlwaysInlining); + } if (Arg *A = Args.getLastArg(OPT_fveclib)) { StringRef Name = A->getValue(); Index: cfe/trunk/test/CodeGen/inline-optim.cc =================================================================== --- cfe/trunk/test/CodeGen/inline-optim.cc +++ cfe/trunk/test/CodeGen/inline-optim.cc @@ -0,0 +1,26 @@ +// Make sure -finline-functions family flags are behaving correctly. + +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s +// RUN: %clang_cc1 -O3 -fno-inline-functions -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s +// RUN: %clang_cc1 -finline-functions -emit-llvm %s -o - | FileCheck -check-prefix=INLINE %s + +inline int inline_hint(int a, int b) { return(a+b); } + +int inline_no_hint(int a, int b) { return (a/b); } + +inline __attribute__ ((__always_inline__)) int inline_always(int a, int b) { return(a*b); } + +volatile int *pa = (int*) 0x1000; +void foo() { +// NOINLINE-LABEL: @foo +// INLINE-LABEL: @foo +// NOINLINE: call i32 @inline_hint +// INLINE-NOT: call i32 @inline_hint + pa[0] = inline_hint(pa[1],pa[2]); +// NOINLINE-NOT: call i32 @inline_always +// INLINE-NOT: call i32 @inline_always + pa[3] = inline_always(pa[4],pa[5]); +// NOINLINE: call i32 @inline_no_hint +// INLINE-NOT: call i32 @inline_no_hint + pa[6] = inline_no_hint(pa[7], pa[8]); +} Index: cfe/trunk/test/Driver/cl-options.c =================================================================== --- cfe/trunk/test/Driver/cl-options.c +++ cfe/trunk/test/Driver/cl-options.c @@ -97,6 +97,9 @@ // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s // Ob0: -fno-inline +// RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s +// Ob2: -finline-functions + // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s // Od: -O0 @@ -265,7 +268,6 @@ // RUN: /kernel- \ // RUN: /nologo \ // RUN: /Ob1 \ -// RUN: /Ob2 \ // RUN: /openmp- \ // RUN: /RTC1 \ // RUN: /sdl \ Index: cfe/trunk/test/Driver/clang_f_opts.c =================================================================== --- cfe/trunk/test/Driver/clang_f_opts.c +++ cfe/trunk/test/Driver/clang_f_opts.c @@ -285,7 +285,6 @@ // RUN: -fexpensive-optimizations \ // RUN: -fno-expensive-optimizations \ // RUN: -fno-defer-pop \ -// RUN: -finline-functions \ // RUN: -fkeep-inline-functions \ // RUN: -fno-keep-inline-functions \ // RUN: -freorder-blocks \ @@ -353,7 +352,6 @@ // CHECK-WARNING-DAG: optimization flag '-fexpensive-optimizations' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-expensive-optimizations' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-defer-pop' is not supported -// CHECK-WARNING-DAG: optimization flag '-finline-functions' is not supported // CHECK-WARNING-DAG: optimization flag '-fkeep-inline-functions' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-keep-inline-functions' is not supported // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported