@@ -776,7 +776,11 @@ void ReducerWorkItem::readBitcode(MemoryBufferRef Data, LLVMContext &Ctx,
776776}
777777
778778void ReducerWorkItem::writeBitcode (raw_ostream &OutStream) const {
779+ const bool ShouldPreserveUseListOrder = true ;
780+
779781 if (LTOInfo && LTOInfo->IsThinLTO && LTOInfo->EnableSplitLTOUnit ) {
782+ // FIXME: This should not depend on the pass manager. There are hidden
783+ // transforms that may happen inside ThinLTOBitcodeWriterPass
780784 PassBuilder PB;
781785 LoopAnalysisManager LAM;
782786 FunctionAnalysisManager FAM;
@@ -788,7 +792,8 @@ void ReducerWorkItem::writeBitcode(raw_ostream &OutStream) const {
788792 PB.registerLoopAnalyses (LAM);
789793 PB.crossRegisterProxies (LAM, FAM, CGAM, MAM);
790794 ModulePassManager MPM;
791- MPM.addPass (ThinLTOBitcodeWriterPass (OutStream, nullptr ));
795+ MPM.addPass (ThinLTOBitcodeWriterPass (OutStream, nullptr ,
796+ ShouldPreserveUseListOrder));
792797 MPM.run (*M, MAM);
793798 } else {
794799 std::unique_ptr<ModuleSummaryIndex> Index;
@@ -797,8 +802,8 @@ void ReducerWorkItem::writeBitcode(raw_ostream &OutStream) const {
797802 Index = std::make_unique<ModuleSummaryIndex>(
798803 buildModuleSummaryIndex (*M, nullptr , &PSI));
799804 }
800- WriteBitcodeToFile (getModule (), OutStream,
801- /* ShouldPreserveUseListOrder= */ true , Index.get ());
805+ WriteBitcodeToFile (getModule (), OutStream, ShouldPreserveUseListOrder,
806+ Index.get ());
802807 }
803808}
804809
0 commit comments