Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4551,10 +4551,11 @@ // Select the appropriate action. RewriteKind rewriteKind = RK_None; + bool DefaultUnified = Triple.isPS4(); bool UnifiedLTO = Args.hasFlag(options::OPT_funified_lto, options::OPT_fno_unified_lto, - false); + DefaultUnified); if (UnifiedLTO) CmdArgs.push_back("-funified-lto"); @@ -7043,7 +7044,8 @@ bool DefaultsSplitLTOUnit = (WholeProgramVTables || SanitizeArgs.needsLTO()) && - (LTOMode == LTOK_Full || TC.canSplitThinLTOUnit()); + (LTOMode == LTOK_Full || TC.canSplitThinLTOUnit()) || + UnifiedLTO; bool SplitLTOUnit = Args.hasFlag(options::OPT_fsplit_lto_unit, options::OPT_fno_split_lto_unit, DefaultsSplitLTOUnit); Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -1754,6 +1754,13 @@ Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S; } + if (Opts.UnifiedLTO) { + if (T.getOS() == llvm::Triple::PS4) + Opts.EnableSplitLTOUnit = false; + else + Opts.EnableSplitLTOUnit = true; + } + if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) { if (IK.getLanguage() != Language::LLVM_IR) Diags.Report(diag::err_drv_argument_only_allowed_with) Index: llvm/include/llvm/Transforms/Utils/ModuleUtils.h =================================================================== --- llvm/include/llvm/Transforms/Utils/ModuleUtils.h +++ llvm/include/llvm/Transforms/Utils/ModuleUtils.h @@ -105,7 +105,7 @@ /// If the module has no strong external symbols (such a module may still have a /// semantic effect if it performs global initialization), we cannot produce a /// unique identifier for this module, so we return the empty string. -std::string getUniqueModuleId(Module *M); +std::string getUniqueModuleId(Module *M, bool UnifiedLTO = false); /// Embed the memory buffer \p Buf into the module \p M as a global using the /// specified section name.