add -fthinlto-index= option to clang-cl
authorBob Haarman <llvm@inglorion.net>
Mon, 15 Jul 2019 22:50:04 +0000 (22:50 +0000)
committerBob Haarman <llvm@inglorion.net>
Mon, 15 Jul 2019 22:50:04 +0000 (22:50 +0000)
Summary:
This adds a -fthinlto-index= option to clang-cl, which allows it to
be used to drive ThinLTO backend passes. This allows clang-cl to be
used for distributed ThinLTO.

Reviewers: tejohnson, pcc, rnk

Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64458

llvm-svn: 366146

clang/include/clang/Driver/Options.td
clang/test/Driver/cl-thinlto-backend.c [new file with mode: 0644]

index 957483c..dfd27fa 100644 (file)
@@ -1270,7 +1270,7 @@ def flto_jobs_EQ : Joined<["-"], "flto-jobs=">,
            "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<f_Group>,
+  Flags<[CoreOption, CC1Option]>, Group<f_Group>,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
                                 Group<f_Group>, Flags<[DriverOption, CoreOption]>;
diff --git a/clang/test/Driver/cl-thinlto-backend.c b/clang/test/Driver/cl-thinlto-backend.c
new file mode 100644 (file)
index 0000000..a948c4e
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: %clang_cl -c -flto=thin -Fo%t.obj %s
+// RUN: llvm-lto2 run -thinlto-distributed-indexes -o %t.exe %t.obj
+
+// -fthinlto_index should be passed to cc1
+// RUN: %clang_cl -### -c -fthinlto-index=%t.thinlto.bc -Fo%t1.obj \
+// RUN:     %t.obj 2>&1 | FileCheck %s
+
+// CHECK: -fthinlto-index=
+// CHECK: "-x" "ir"