Skip to content

Commit 04ec2c8

Browse files
committed
[ownership] Move OME out of the diagnostics pipeline behind a flag.
Once the flag is flipped, ownership stripping will no longer be done in the diagnostics pipeline. Instead what will happen is that: * Onone: At -Onone, we run the entire diagnostics pipeline with ownership enabled and do not strip ownership until after we serialize in the Onone "optimization" pass pipeline plan. * -O: At -O, to temporarily work around serialization issues with transparent functions, we strip ownership from all but transparent functions at the beginning of the performance pipeline, serialize, and then strip ownership from transparent functions. For this to work, I needed to make sure that the performance pipeline passes that do not support ownership SIL, just skip such functions. So the transparent functions will arrive (mostly) untouched in serialized SIL and the rest of the pipeline will optimize non-transparent functions as they should. The key thing about the -O change is that it /should/ be performance neutral since after we serialize we re-run the entire pipeline so we can optimize semantic functions that we only can inline after we serialize.
1 parent fccd75e commit 04ec2c8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

include/swift/AST/SILOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ class SILOptions {
135135
/// Enable large loadable types IRGen pass.
136136
bool EnableLargeLoadableTypes = true;
137137

138+
/// Should the default pass pipelines strip ownership during the diagnostic
139+
/// pipeline.
140+
bool StripOwnershipDuringDiagnosticsPipeline = true;
141+
138142
/// The name of the file to which the backend should save YAML optimization
139143
/// records.
140144
std::string OptRecordFile;

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ static void addMandatoryOptPipeline(SILPassPipelinePlan &P) {
103103
P.addSemanticARCOpts();
104104
}
105105
P.addClosureLifetimeFixup();
106-
P.addOwnershipModelEliminator();
106+
if (Options.StripOwnershipDuringDiagnosticsPipeline)
107+
P.addOwnershipModelEliminator();
107108
P.addMandatoryInlining();
108109
P.addMandatorySILLinker();
109110

@@ -294,6 +295,11 @@ void addSSAPasses(SILPassPipelinePlan &P, OptimizationLevelKind OpLevel) {
294295
// which reduces the ability of the compiler to optimize clients
295296
// importing this module.
296297
P.addSerializeSILPass();
298+
299+
// Now strip any transparent functions that still have ownership.
300+
if (!P.getOptions().StripOwnershipDuringDiagnosticsPipeline)
301+
P.addOwnershipModelEliminator();
302+
297303
if (P.getOptions().StopOptimizationAfterSerialization)
298304
return;
299305

@@ -371,6 +377,10 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
371377
// we do not spend time optimizing them.
372378
P.addDeadFunctionElimination();
373379

380+
// Strip ownership from non-transparent functions.
381+
if (!P.getOptions().StripOwnershipDuringDiagnosticsPipeline)
382+
P.addNonTransparentFunctionOwnershipModelEliminator();
383+
374384
// Start by cloning functions from stdlib.
375385
P.addPerformanceSILLinker();
376386

@@ -643,6 +653,10 @@ SILPassPipelinePlan::getOnonePassPipeline(const SILOptions &Options) {
643653
// Finally serialize the SIL if we are asked to.
644654
P.addSerializeSILPass();
645655

656+
// And then strip ownership before we IRGen.
657+
if (!Options.StripOwnershipDuringDiagnosticsPipeline)
658+
P.addOwnershipModelEliminator();
659+
646660
return P;
647661
}
648662

0 commit comments

Comments
 (0)