Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -957,19 +957,19 @@ def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; -def flto_EQ : Joined<["-"], "flto=">, Flags<[CC1Option]>, Group, +def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Set LTO mode to either 'full' or 'thin'">; def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Enable LTO in 'full' mode">; def fno_lto : Flag<["-"], "fno-lto">, Group, HelpText<"Disable LTO mode (default)">; def flto_jobs_EQ : Joined<["-"], "flto-jobs=">, - Flags<[CC1Option]>, Group, + Flags<[CoreOption, CC1Option]>, Group, HelpText<"Controls the backend parallelism of -flto=thin (default " "of 0 means the number of threads will be derived from " "the number of CPUs detected)">; def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">, - Flags<[CC1Option]>, Group, + Flags<[CoreOption, CC1Option]>, Group, HelpText<"Perform ThinLTO importing using provided function summary index">; def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">, Group, Flags<[DriverOption, CoreOption]>; Index: test/Driver/cl-lto.c =================================================================== --- /dev/null +++ test/Driver/cl-lto.c @@ -0,0 +1,25 @@ +// -flto causes a switch to llvm-bc object files. +// RUN: %clang_cl -ccc-print-phases -c -flto -- %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-COMPILE-ACTIONS < %t %s +// +// CHECK-COMPILE-ACTIONS: 2: compiler, {1}, ir +// CHECK-COMPILE-ACTIONS: 3: backend, {2}, lto-bc + +// RUN: %clang_cl -ccc-print-phases -flto -- %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-COMPILELINK-ACTIONS < %t %s +// +// CHECK-COMPILELINK-ACTIONS: 0: input, "{{.*}}lto.c", c +// CHECK-COMPILELINK-ACTIONS: 1: preprocessor, {0}, cpp-output +// CHECK-COMPILELINK-ACTIONS: 2: compiler, {1}, ir +// CHECK-COMPILELINK-ACTIONS: 3: backend, {2}, lto-bc +// CHECK-COMPILELINK-ACTIONS: 4: linker, {3}, image + +// llvm-bc and llvm-ll outputs need to match regular suffixes +// (unfortunately). +// RUN: %clang_cl -### -flto -- %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-COMPILELINK-SUFFIXES < %t %s +// +// CHECK-COMPILELINK-SUFFIXES: "-emit-llvm-bc" +// CHECK-COMPILELINK-SUFFIXES-SAME: "-o" "{{.*}}cl-lto{{[^ ]*}}.obj" +// CHECK-COMPILELINK-SUFFIXES-SAME: "-x" "c" "{{.*}}cl-lto.c" +// CHECK-COMPILELINK-SUFFIXES: "{{.*}}cl-lto.{{(exe)}}" {{.*}}"{{.*}}cl-lto{{[^ ]*}}.obj" Index: test/Driver/cl-thinlto.c =================================================================== --- /dev/null +++ test/Driver/cl-thinlto.c @@ -0,0 +1,33 @@ +// -flto=thin causes a switch to llvm-bc object files. +// RUN: %clang_cl -ccc-print-phases -c -flto=thin -- %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-COMPILE-ACTIONS < %t %s +// +// CHECK-COMPILE-ACTIONS: 2: compiler, {1}, ir +// CHECK-COMPILE-ACTIONS: 3: backend, {2}, lto-bc + +// RUN: %clang_cl -ccc-print-phases -flto=thin -- %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-COMPILELINK-ACTIONS < %t %s +// +// CHECK-COMPILELINK-ACTIONS: 0: input, "{{.*}}thinlto.c", c +// CHECK-COMPILELINK-ACTIONS: 1: preprocessor, {0}, cpp-output +// CHECK-COMPILELINK-ACTIONS: 2: compiler, {1}, ir +// CHECK-COMPILELINK-ACTIONS: 3: backend, {2}, lto-bc +// CHECK-COMPILELINK-ACTIONS: 4: linker, {3}, image + +// -flto=thin should take precedence over earlier -fno-lto and -flto=full. +// RUN: %clang_cl -### -fuse-ld=lld -flto=full -fno-lto -flto=thin -- %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-ACTION < %t %s +// +// CHECK-LINK-THIN-ACTION: "-cc1"{{.*}}"-flto=thin" + +// Check that subsequent -flto=full takes precedence +// RUN: %clang_cl -### -flto=thin -flto=full -- %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s +// +// CHECK-LINK-FULL-ACTION: "-cc1"{{.*}}"-flto=full" + +// Check that subsequent -fno-lto takes precedence +// RUN: %clang_cl -### %s -flto=thin -fno-lto 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s +// +// CHECK-LINK-NOLTO-ACTION-NOT: "-cc1"{{.*}}"-flto"