Index: clang/lib/CodeGen/BackendUtil.cpp =================================================================== --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -164,6 +164,16 @@ std::unique_ptr &OS, std::unique_ptr &DwoOS); + /// Check whether we should emit a module summary. + /// The module summary should be emitted by default for Regular LTO + /// except for ld64 targets. + /// + /// \return True if the module summary should be emitted. + bool shouldEmitLTOSummary() const { + return CodeGenOpts.PrepareForLTO && !CodeGenOpts.DisableLLVMPasses && + TargetTriple.getVendor() != llvm::Triple::Apple; + } + public: EmitAssemblyHelper(DiagnosticsEngine &_Diags, const HeaderSearchOptions &HeaderSearchOpts, @@ -1054,9 +1064,7 @@ } else { // Emit a module summary by default for Regular LTO except for ld64 // targets - bool EmitLTOSummary = - (CodeGenOpts.PrepareForLTO && !CodeGenOpts.DisableLLVMPasses && - TargetTriple.getVendor() != llvm::Triple::Apple); + bool EmitLTOSummary = shouldEmitLTOSummary(); if (EmitLTOSummary) { if (!TheModule->getModuleFlag("ThinLTO")) TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0)); @@ -1064,7 +1072,6 @@ TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit", uint32_t(1)); } - PerModulePasses.add(createBitcodeWriterPass( *OS, CodeGenOpts.EmitLLVMUseLists, EmitLTOSummary)); } @@ -1470,9 +1477,7 @@ } else { // Emit a module summary by default for Regular LTO except for ld64 // targets - bool EmitLTOSummary = - (CodeGenOpts.PrepareForLTO && !CodeGenOpts.DisableLLVMPasses && - TargetTriple.getVendor() != llvm::Triple::Apple); + bool EmitLTOSummary = shouldEmitLTOSummary(); if (EmitLTOSummary) { if (!TheModule->getModuleFlag("ThinLTO")) TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));