@@ -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));
@@ -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
@@ -591,7 +594,8 @@ llvm::ThinLTOBitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) {
591594 [&FAM](Function &F) -> AAResults & {
592595 return FAM.getResult <AAManager>(F);
593596 },
594- M, &AM.getResult <ModuleSummaryIndexAnalysis>(M));
597+ M, &AM.getResult <ModuleSummaryIndexAnalysis>(M),
598+ ShouldPreserveUseListOrder);
595599
596600 return Changed ? PreservedAnalyses::none () : PreservedAnalyses::all ();
597601}
0 commit comments