Forwarding manually, since it appears when I manually added reviewers (Rafael and Duncan) and cfe-commits as the subscriber in Phab, it only sent email to Rafael.
Thanks, Teresa ---------- Forwarded message ---------- From: Teresa Johnson <tejohn...@google.com> Date: Mon, Aug 10, 2015 at 8:58 AM Subject: [PATCH] D11906: Clang support for -fthinlto. To: tejohn...@google.com tejohnson created this revision. Add clang support for -fthinlto option, which is used to set the EmitThinLTOIndex code gen option on compiles, and the thinlto gold plugin option on links. Dependent on LLVM/gold patch http://reviews.llvm.org/D11905. http://reviews.llvm.org/D11906 Files: include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/BackendUtil.cpp lib/Driver/Driver.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp -- Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -516,6 +516,7 @@ Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions); Opts.PrepareForLTO = Args.hasArg(OPT_flto); + Opts.EmitThinLTOIndex = Args.hasArg(OPT_fthinlto); Opts.MSVolatile = Args.hasArg(OPT_fms_volatile); Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -1648,6 +1648,9 @@ std::string CPU = getCPUName(Args, ToolChain.getTriple()); if (!CPU.empty()) CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=mcpu=") + CPU)); + + if (Args.hasArg(options::OPT_fthinlto)) + CmdArgs.push_back("-plugin-opt=thinlto"); } /// This is a helper function for validating the optional refinement step @@ -2761,6 +2764,8 @@ // preprocessing, precompiling or assembling. Args.ClaimAllArgs(options::OPT_flto); Args.ClaimAllArgs(options::OPT_fno_lto); + Args.ClaimAllArgs(options::OPT_fthinlto); + Args.ClaimAllArgs(options::OPT_fno_thinlto); } static void appendUserToPath(SmallVectorImpl<char> &Result) { @@ -3027,6 +3032,9 @@ "Invalid action for clang tool."); if (JA.getType() == types::TY_LTO_IR || JA.getType() == types::TY_LTO_BC) { + // Note that both -flto and -fthinlto use the TY_LTO_* types. + // Setting -flto here will enable the PrepareForLTO codegen option, + // which we do want for -fthinlto compiles as well. CmdArgs.push_back("-flto"); } if (JA.getType() == types::TY_Nothing) { @@ -3059,6 +3067,10 @@ // the use-list order, since serialization to bitcode is part of the flow. if (JA.getType() == types::TY_LLVM_BC) CmdArgs.push_back("-emit-llvm-uselists"); + + if (Args.hasArg(options::OPT_fthinlto)) { + CmdArgs.push_back("-fthinlto"); + } } // We normally speed up the clang process a bit by skipping destructors at Index: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1583,7 +1583,8 @@ } bool Driver::IsUsingLTO(const ArgList &Args) const { - return Args.hasFlag(options::OPT_flto, options::OPT_fno_lto, false); + return Args.hasFlag(options::OPT_flto, options::OPT_fno_lto, false) || + Args.hasFlag(options::OPT_fthinlto, options::OPT_fno_thinlto, false); } void Driver::BuildJobs(Compilation &C) const { Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -618,7 +618,8 @@ case Backend_EmitBC: getPerModulePasses()->add( - createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists)); + createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, + CodeGenOpts.EmitThinLTOIndex)); break; case Backend_EmitLL: Index: include/clang/Frontend/CodeGenOptions.def =================================================================== --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -72,7 +72,9 @@ CODEGENOPT(InstrumentForProfiling , 1, 0) ///< Set when -pg is enabled. CODEGENOPT(LessPreciseFPMAD , 1, 0) ///< Enable less precise MAD instructions to ///< be generated. -CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the +CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto or -fthinlto is enabled + ///< on the compile step. +CODEGENOPT(EmitThinLTOIndex , 1, 0) ///< Set when -fthinlto is enabled on the ///< compile step. CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants. CODEGENOPT(MergeFunctions , 1, 0) ///< Set when -fmerge-functions is enabled. Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -682,6 +682,8 @@ def flto_EQ : Joined<["-"], "flto=">, Group<clang_ignored_gcc_optimization_f_Group>; def flto : Flag<["-"], "flto">, Flags<[CC1Option]>, Group<f_Group>; def fno_lto : Flag<["-"], "fno-lto">, Group<f_Group>; +def fthinlto : Flag<["-"], "fthinlto">, Flags<[CC1Option]>, Group<f_Group>; +def fno_thinlto : Flag<["-"], "fno-thinlto">, Group<f_Group>; def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">, Group<f_Group>, Flags<[DriverOption, CoreOption]>; def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group<f_Group>;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits