@@ -274,7 +274,8 @@ static bool enableUnifiedLTO(Module &M) {
274274// regular LTO bitcode file to OS.
275275void splitAndWriteThinLTOBitcode (
276276 raw_ostream &OS, raw_ostream *ThinLinkOS,
277- function_ref<AAResults &(Function &)> AARGetter, Module &M) {
277+ function_ref<AAResults &(Function &)> AARGetter, Module &M,
278+ const bool ShouldPreserveUseListOrder) {
278279 std::string ModuleId = getUniqueModuleId (&M);
279280 if (ModuleId.empty ()) {
280281 assert (!enableUnifiedLTO (M));
@@ -283,14 +284,14 @@ void splitAndWriteThinLTOBitcode(
283284 ProfileSummaryInfo PSI (M);
284285 M.addModuleFlag (Module::Error, " ThinLTO" , uint32_t (0 ));
285286 ModuleSummaryIndex Index = buildModuleSummaryIndex (M, nullptr , &PSI);
286- WriteBitcodeToFile (M, OS, /* ShouldPreserveUseListOrder= */ false , &Index,
287+ WriteBitcodeToFile (M, OS, ShouldPreserveUseListOrder, &Index,
287288 /* UnifiedLTO=*/ false );
288289
289290 if (ThinLinkOS)
290291 // We don't have a ThinLTO part, but still write the module to the
291292 // ThinLinkOS if requested so that the expected output file is produced.
292- WriteBitcodeToFile (M, *ThinLinkOS, /* ShouldPreserveUseListOrder= */ false ,
293- &Index, /* UnifiedLTO=*/ false );
293+ WriteBitcodeToFile (M, *ThinLinkOS, ShouldPreserveUseListOrder, &Index ,
294+ /* UnifiedLTO=*/ false );
294295
295296 return ;
296297 }
@@ -487,9 +488,9 @@ void splitAndWriteThinLTOBitcode(
487488 // be used in the backends, and use that in the minimized bitcode
488489 // produced for the full link.
489490 ModuleHash ModHash = {{0 }};
490- W.writeModule (M, /* ShouldPreserveUseListOrder= */ false , &Index,
491+ W.writeModule (M, ShouldPreserveUseListOrder, &Index,
491492 /* GenerateHash=*/ true , &ModHash);
492- W.writeModule (*MergedM, /* ShouldPreserveUseListOrder= */ false , &MergedMIndex);
493+ W.writeModule (*MergedM, ShouldPreserveUseListOrder, &MergedMIndex);
493494 W.writeSymtab ();
494495 W.writeStrtab ();
495496 OS << Buffer;
@@ -530,13 +531,15 @@ bool hasTypeMetadata(Module &M) {
530531
531532bool writeThinLTOBitcode (raw_ostream &OS, raw_ostream *ThinLinkOS,
532533 function_ref<AAResults &(Function &)> AARGetter,
533- Module &M, const ModuleSummaryIndex *Index) {
534+ Module &M, const ModuleSummaryIndex *Index,
535+ const bool ShouldPreserveUseListOrder) {
534536 std::unique_ptr<ModuleSummaryIndex> NewIndex = nullptr ;
535537 // See if this module has any type metadata. If so, we try to split it
536538 // or at least promote type ids to enable WPD.
537539 if (hasTypeMetadata (M)) {
538540 if (enableSplitLTOUnit (M)) {
539- splitAndWriteThinLTOBitcode (OS, ThinLinkOS, AARGetter, M);
541+ splitAndWriteThinLTOBitcode (OS, ThinLinkOS, AARGetter, M,
542+ ShouldPreserveUseListOrder);
540543 return true ;
541544 }
542545 // Promote type ids as needed for index-based WPD.
@@ -564,7 +567,7 @@ bool writeThinLTOBitcode(raw_ostream &OS, raw_ostream *ThinLinkOS,
564567 // be used in the backends, and use that in the minimized bitcode
565568 // produced for the full link.
566569 ModuleHash ModHash = {{0 }};
567- WriteBitcodeToFile (M, OS, /* ShouldPreserveUseListOrder= */ false , Index,
570+ WriteBitcodeToFile (M, OS, ShouldPreserveUseListOrder, Index,
568571 /* GenerateHash=*/ true , &ModHash);
569572 // If a minimized bitcode module was requested for the thin link, only
570573 // the information that is needed by thin link will be written in the
@@ -590,7 +593,8 @@ llvm::ThinLTOBitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) {
590593 [&FAM](Function &F) -> AAResults & {
591594 return FAM.getResult <AAManager>(F);
592595 },
593- M, &AM.getResult <ModuleSummaryIndexAnalysis>(M));
596+ M, &AM.getResult <ModuleSummaryIndexAnalysis>(M),
597+ ShouldPreserveUseListOrder);
594598
595599 return Changed ? PreservedAnalyses::none () : PreservedAnalyses::all ();
596600}
0 commit comments