@@ -769,7 +769,11 @@ void ReducerWorkItem::readBitcode(MemoryBufferRef Data, LLVMContext &Ctx,
769769}
770770
771771void ReducerWorkItem::writeBitcode (raw_ostream &OutStream) const {
772+ const bool ShouldPreserveUseListOrder = true ;
773+
772774 if (LTOInfo && LTOInfo->IsThinLTO && LTOInfo->EnableSplitLTOUnit ) {
775+ // FIXME: This should not depend on the pass manager. There are hidden
776+ // transforms that may happen inside ThinLTOBitcodeWriterPass
773777 PassBuilder PB;
774778 LoopAnalysisManager LAM;
775779 FunctionAnalysisManager FAM;
@@ -781,7 +785,8 @@ void ReducerWorkItem::writeBitcode(raw_ostream &OutStream) const {
781785 PB.registerLoopAnalyses (LAM);
782786 PB.crossRegisterProxies (LAM, FAM, CGAM, MAM);
783787 ModulePassManager MPM;
784- MPM.addPass (ThinLTOBitcodeWriterPass (OutStream, nullptr ));
788+ MPM.addPass (ThinLTOBitcodeWriterPass (OutStream, nullptr ,
789+ ShouldPreserveUseListOrder));
785790 MPM.run (*M, MAM);
786791 } else {
787792 std::unique_ptr<ModuleSummaryIndex> Index;
@@ -790,8 +795,8 @@ void ReducerWorkItem::writeBitcode(raw_ostream &OutStream) const {
790795 Index = std::make_unique<ModuleSummaryIndex>(
791796 buildModuleSummaryIndex (*M, nullptr , &PSI));
792797 }
793- WriteBitcodeToFile (getModule (), OutStream,
794- /* ShouldPreserveUseListOrder= */ true , Index.get ());
798+ WriteBitcodeToFile (getModule (), OutStream, ShouldPreserveUseListOrder,
799+ Index.get ());
795800 }
796801}
797802
0 commit comments