@@ -274,7 +274,8 @@ static bool enableUnifiedLTO(Module &M) {
274
274
// regular LTO bitcode file to OS.
275
275
void splitAndWriteThinLTOBitcode (
276
276
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) {
278
279
std::string ModuleId = getUniqueModuleId (&M);
279
280
if (ModuleId.empty ()) {
280
281
assert (!enableUnifiedLTO (M));
@@ -487,9 +488,9 @@ void splitAndWriteThinLTOBitcode(
487
488
// be used in the backends, and use that in the minimized bitcode
488
489
// produced for the full link.
489
490
ModuleHash ModHash = {{0 }};
490
- W.writeModule (M, /* ShouldPreserveUseListOrder= */ false , &Index,
491
+ W.writeModule (M, ShouldPreserveUseListOrder, &Index,
491
492
/* GenerateHash=*/ true , &ModHash);
492
- W.writeModule (*MergedM, /* ShouldPreserveUseListOrder= */ false , &MergedMIndex);
493
+ W.writeModule (*MergedM, ShouldPreserveUseListOrder, &MergedMIndex);
493
494
W.writeSymtab ();
494
495
W.writeStrtab ();
495
496
OS << Buffer;
@@ -530,13 +531,15 @@ bool hasTypeMetadata(Module &M) {
530
531
531
532
bool writeThinLTOBitcode (raw_ostream &OS, raw_ostream *ThinLinkOS,
532
533
function_ref<AAResults &(Function &)> AARGetter,
533
- Module &M, const ModuleSummaryIndex *Index) {
534
+ Module &M, const ModuleSummaryIndex *Index,
535
+ const bool ShouldPreserveUseListOrder) {
534
536
std::unique_ptr<ModuleSummaryIndex> NewIndex = nullptr ;
535
537
// See if this module has any type metadata. If so, we try to split it
536
538
// or at least promote type ids to enable WPD.
537
539
if (hasTypeMetadata (M)) {
538
540
if (enableSplitLTOUnit (M)) {
539
- splitAndWriteThinLTOBitcode (OS, ThinLinkOS, AARGetter, M);
541
+ splitAndWriteThinLTOBitcode (OS, ThinLinkOS, AARGetter, M,
542
+ ShouldPreserveUseListOrder);
540
543
return true ;
541
544
}
542
545
// Promote type ids as needed for index-based WPD.
@@ -564,7 +567,7 @@ bool writeThinLTOBitcode(raw_ostream &OS, raw_ostream *ThinLinkOS,
564
567
// be used in the backends, and use that in the minimized bitcode
565
568
// produced for the full link.
566
569
ModuleHash ModHash = {{0 }};
567
- WriteBitcodeToFile (M, OS, /* ShouldPreserveUseListOrder= */ false , Index,
570
+ WriteBitcodeToFile (M, OS, ShouldPreserveUseListOrder, Index,
568
571
/* GenerateHash=*/ true , &ModHash);
569
572
// If a minimized bitcode module was requested for the thin link, only
570
573
// the information that is needed by thin link will be written in the
@@ -591,7 +594,8 @@ llvm::ThinLTOBitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) {
591
594
[&FAM](Function &F) -> AAResults & {
592
595
return FAM.getResult <AAManager>(F);
593
596
},
594
- M, &AM.getResult <ModuleSummaryIndexAnalysis>(M));
597
+ M, &AM.getResult <ModuleSummaryIndexAnalysis>(M),
598
+ ShouldPreserveUseListOrder);
595
599
596
600
return Changed ? PreservedAnalyses::none () : PreservedAnalyses::all ();
597
601
}
0 commit comments