@@ -231,7 +231,9 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
231231 P.addDiagnoseLifetimeIssues ();
232232 }
233233
234- P.addGlobalOpt ();
234+ P.addOnoneSimplification ();
235+ P.addInitializeStaticGlobals ();
236+
235237 P.addPerformanceDiagnostics ();
236238
237239 // Canonical swift requires all non cond_br critical edges to be split.
@@ -627,10 +629,6 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
627629 // is linked in from the stdlib.
628630 P.addTempRValueOpt ();
629631
630- // Needed to serialize static initializers of globals for cross-module
631- // optimization.
632- P.addGlobalOpt ();
633-
634632 // Add the outliner pass (Osize).
635633 P.addOutliner ();
636634}
@@ -674,7 +672,6 @@ static void addHighLevelModulePipeline(SILPassPipelinePlan &P) {
674672 P.addComputeSideEffects ();
675673 P.addStackPromotion ();
676674
677- P.addGlobalOpt ();
678675 P.addLetPropertiesOpt ();
679676}
680677
@@ -699,25 +696,26 @@ static void addMidLevelFunctionPipeline(SILPassPipelinePlan &P) {
699696static void addClosureSpecializePassPipeline (SILPassPipelinePlan &P) {
700697 P.startPipeline (" ClosureSpecialize" );
701698 P.addDeadFunctionAndGlobalElimination ();
699+ P.addReadOnlyGlobalVariablesPass ();
702700 P.addTargetConstantFolding ();
703701 P.addDeadStoreElimination ();
704702 P.addDeadObjectElimination ();
705703
706- // These few passes are needed to cleanup between loop unrolling and GlobalOpt .
704+ // These few passes are needed to cleanup between loop unrolling and InitializeStaticGlobals .
707705 // This is needed to fully optimize static small String constants.
708706 P.addSimplifyCFG ();
709707 P.addSILCombine ();
710708 P.addPerformanceConstantPropagation ();
711709 P.addSimplifyCFG ();
712-
710+ P.addSimplification ();
711+
712+ P.addInitializeStaticGlobals ();
713+
713714 // ComputeEffects should be done at the end of a function-pipeline. The next
714- // pass (GlobalOpt ) is a module pass, so this is the end of a function-pipeline.
715+ // pass (LetPropertiesOpt ) is a module pass, so this is the end of a function-pipeline.
715716 P.addComputeEscapeEffects ();
716717 P.addComputeSideEffects ();
717718
718- // Hoist globals out of loops.
719- // Global-init functions should not be inlined GlobalOpt is done.
720- P.addGlobalOpt ();
721719 P.addLetPropertiesOpt ();
722720
723721 // Propagate constants into closures and convert to static dispatch. This
@@ -984,7 +982,6 @@ SILPassPipelinePlan::getOnonePassPipeline(const SILOptions &Options) {
984982 // in the editor.
985983 P.startPipeline (" Non-Diagnostic Mandatory Optimizations" );
986984 P.addForEachLoopUnroll ();
987- P.addOnoneSimplification ();
988985
989986 // TODO: MandatoryARCOpts should be subsumed by CopyPropagation. There should
990987 // be no need to run another analysis of copies at -Onone.
0 commit comments