inglorion created this revision. inglorion added reviewers: tejohnson, pcc, rnk. Herald added subscribers: arphaman, dexonsmith, steven_wu, mehdi_amini. Herald added a project: clang.
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. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D64458 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/test/Driver/cl-thinlto-backend.c Index: clang/test/Driver/cl-thinlto-backend.c =================================================================== --- /dev/null +++ clang/test/Driver/cl-thinlto-backend.c @@ -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" Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -2119,6 +2119,13 @@ Diag(clang::diag::warn_drv_treating_input_as_cxx) << getTypeName(OldTy) << getTypeName(Ty); } + + // If the driver is invoked as clang-cl with -thinlto-index=, + // extensions that normally identify native object files actually + // identify LLVM bitcode files. + if (IsCLMode() && Ty == types::TY_Object && + Args.hasArgNoClaim(options::OPT_fthinlto_index_EQ)) + Ty = types::TY_LLVM_BC; } // -ObjC and -ObjC++ override the default language, but only for "source Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -1270,7 +1270,7 @@ "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]>;
Index: clang/test/Driver/cl-thinlto-backend.c =================================================================== --- /dev/null +++ clang/test/Driver/cl-thinlto-backend.c @@ -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" Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -2119,6 +2119,13 @@ Diag(clang::diag::warn_drv_treating_input_as_cxx) << getTypeName(OldTy) << getTypeName(Ty); } + + // If the driver is invoked as clang-cl with -thinlto-index=, + // extensions that normally identify native object files actually + // identify LLVM bitcode files. + if (IsCLMode() && Ty == types::TY_Object && + Args.hasArgNoClaim(options::OPT_fthinlto_index_EQ)) + Ty = types::TY_LLVM_BC; } // -ObjC and -ObjC++ override the default language, but only for "source Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -1270,7 +1270,7 @@ "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]>;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits