Index: llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp =================================================================== --- llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp +++ llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp @@ -200,13 +200,19 @@ function_ref AARGetter, Module &M) { std::string ModuleId = getUniqueModuleId(&M); if (ModuleId.empty()) { - // We couldn't generate a module ID for this module, just write it out as a - // regular LTO module. - WriteBitcodeToFile(M, OS); + // We couldn't generate a module ID for this module, write it out as a + // regular LTO module with an index for summary-based dead stripping. + ProfileSummaryInfo PSI(M); + M.addModuleFlag(Module::Error, "ThinLTO", uint32_t(0)); + ModuleSummaryIndex Index = buildModuleSummaryIndex(M, nullptr, &PSI); + WriteBitcodeToFile(M, OS, /*ShouldPreserveUseListOrder=*/false, &Index); + if (ThinLinkOS) // We don't have a ThinLTO part, but still write the module to the // ThinLinkOS if requested so that the expected output file is produced. - WriteBitcodeToFile(M, *ThinLinkOS); + WriteBitcodeToFile(M, *ThinLinkOS, /*ShouldPreserveUseListOrder=*/false, + &Index); + return; } Index: llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll =================================================================== --- llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll +++ llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll @@ -5,6 +5,7 @@ ; copy of the regular module. ; RUN: diff %t %t2 +; BCA: