Skip to content

Commit fe39c72

Browse files
authored
Merge pull request #32390 from gottesmm/pr-c38328b82781ec804d14966507bcc7995465d3bf
[arc] Change guaranteed arc opts to be based on SemanticARCOpts and move from Diagnostic pipeline -> Onone pipeline.
2 parents 0de7fb8 + 702c1bc commit fe39c72

18 files changed

+121
-505
lines changed

lib/SILOptimizer/Mandatory/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ target_sources(swiftSILOptimizer PRIVATE
1212
DiagnoseStaticExclusivity.cpp
1313
DiagnoseUnreachable.cpp
1414
Differentiation.cpp
15-
GuaranteedARCOpts.cpp
1615
IRGenPrepare.cpp
1716
MandatoryInlining.cpp
1817
PredictableMemOpt.cpp

lib/SILOptimizer/Mandatory/GuaranteedARCOpts.cpp

Lines changed: 0 additions & 260 deletions
This file was deleted.

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,15 @@ static void addDefiniteInitialization(SILPassPipelinePlan &P) {
7878
P.addRawSILInstLowering();
7979
}
8080

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");
8390
P.addSILGenCleanup();
8491
P.addDiagnoseInvalidEscapingCaptures();
8592
P.addDiagnoseStaticExclusivity();
@@ -142,7 +149,6 @@ static void addMandatoryOptPipeline(SILPassPipelinePlan &P) {
142149
// dead allocations.
143150
P.addPredictableDeadAllocationElimination();
144151

145-
P.addGuaranteedARCOpts();
146152
P.addDiagnoseUnreachable();
147153
P.addDiagnoseInfiniteRecursion();
148154
P.addYieldOnceCheck();
@@ -169,7 +175,7 @@ SILPassPipelinePlan::getDiagnosticPassPipeline(const SILOptions &Options) {
169175
}
170176

171177
// Otherwise run the rest of diagnostics.
172-
addMandatoryOptPipeline(P);
178+
addMandatoryDiagnosticOptPipeline(P);
173179

174180
if (SILViewGuaranteedCFG) {
175181
addCFGPrinterPipeline(P, "SIL View Guaranteed CFG");
@@ -738,9 +744,14 @@ SILPassPipelinePlan
738744
SILPassPipelinePlan::getOnonePassPipeline(const SILOptions &Options) {
739745
SILPassPipelinePlan P(Options);
740746

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");
742752
P.addForEachLoopUnroll();
743753
P.addMandatoryCombine();
754+
P.addGuaranteedARCOpts();
744755

745756
// First serialize the SIL if we are asked to.
746757
P.startPipeline("Serialization");

0 commit comments

Comments
 (0)