@@ -78,8 +78,15 @@ static void addDefiniteInitialization(SILPassPipelinePlan &P) {
78
78
P.addRawSILInstLowering ();
79
79
}
80
80
81
- static void addMandatoryOptPipeline (SILPassPipelinePlan &P) {
82
- P.startPipeline (" Guaranteed Passes" );
81
+ // This pipeline defines a set of mandatory diagnostic passes and a set of
82
+ // supporting optimization passes that enable those diagnostics. These are run
83
+ // before any performance optimizations and in contrast to those optimizations
84
+ // _IS_ run when SourceKit emits diagnostics.
85
+ //
86
+ // Any passes not needed for diagnostic emission that need to run at -Onone
87
+ // should be in the -Onone pass pipeline and the prepare optimizations pipeline.
88
+ static void addMandatoryDiagnosticOptPipeline (SILPassPipelinePlan &P) {
89
+ P.startPipeline (" Mandatory Diagnostic Passes + Enabling Optimization Passes" );
83
90
P.addSILGenCleanup ();
84
91
P.addDiagnoseInvalidEscapingCaptures ();
85
92
P.addDiagnoseStaticExclusivity ();
@@ -142,7 +149,6 @@ static void addMandatoryOptPipeline(SILPassPipelinePlan &P) {
142
149
// dead allocations.
143
150
P.addPredictableDeadAllocationElimination ();
144
151
145
- P.addGuaranteedARCOpts ();
146
152
P.addDiagnoseUnreachable ();
147
153
P.addDiagnoseInfiniteRecursion ();
148
154
P.addYieldOnceCheck ();
@@ -169,7 +175,7 @@ SILPassPipelinePlan::getDiagnosticPassPipeline(const SILOptions &Options) {
169
175
}
170
176
171
177
// Otherwise run the rest of diagnostics.
172
- addMandatoryOptPipeline (P);
178
+ addMandatoryDiagnosticOptPipeline (P);
173
179
174
180
if (SILViewGuaranteedCFG) {
175
181
addCFGPrinterPipeline (P, " SIL View Guaranteed CFG" );
@@ -738,9 +744,14 @@ SILPassPipelinePlan
738
744
SILPassPipelinePlan::getOnonePassPipeline (const SILOptions &Options) {
739
745
SILPassPipelinePlan P (Options);
740
746
741
- P.startPipeline (" Mandatory Combines" );
747
+ // These are optimizations that we do not need to enable diagnostics (or
748
+ // depend on other passes needed for diagnostics). Thus we can run them later
749
+ // and avoid having SourceKit run these passes when just emitting diagnostics
750
+ // in the editor.
751
+ P.startPipeline (" non-Diagnostic Enabling Mandatory Optimizations" );
742
752
P.addForEachLoopUnroll ();
743
753
P.addMandatoryCombine ();
754
+ P.addGuaranteedARCOpts ();
744
755
745
756
// First serialize the SIL if we are asked to.
746
757
P.startPipeline (" Serialization" );
0 commit comments