Skip to content

Commit d7281a1

Browse files
authored
Enable late OME via an experimental flag (swiftlang#39363)
1 parent 3e4dd68 commit d7281a1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ static llvm::cl::opt<bool> SILViewSILGenCFG(
5151
"sil-view-silgen-cfg", llvm::cl::init(false),
5252
llvm::cl::desc("Enable the sil cfg viewer pass before diagnostics"));
5353

54+
static llvm::cl::opt<bool>
55+
SILEnableLateOME("sil-enable-late-ome", llvm::cl::init(false),
56+
llvm::cl::desc("Enable late OwnershipModel elimination"));
57+
5458
//===----------------------------------------------------------------------===//
5559
// Diagnostic Pass Pipeline
5660
//===----------------------------------------------------------------------===//
@@ -365,7 +369,7 @@ void addFunctionPasses(SILPassPipelinePlan &P,
365369
P.addDevirtualizer();
366370
P.addARCSequenceOpts();
367371

368-
if (P.getOptions().EnableOSSAModules) {
372+
if (P.getOptions().EnableOSSAModules || SILEnableLateOME) {
369373
// We earlier eliminated ownership if we are not compiling the stdlib. Now
370374
// handle the stdlib functions, re-simplifying, eliminating ARC as we do.
371375
if (!P.getOptions().DisableCopyPropagation) {
@@ -391,7 +395,7 @@ void addFunctionPasses(SILPassPipelinePlan &P,
391395
}
392396

393397
// Clean up Semantic ARC before we perform additional post-inliner opts.
394-
if (P.getOptions().EnableOSSAModules) {
398+
if (P.getOptions().EnableOSSAModules || SILEnableLateOME) {
395399
if (!P.getOptions().DisableCopyPropagation) {
396400
P.addCopyPropagation();
397401
}
@@ -458,7 +462,7 @@ void addFunctionPasses(SILPassPipelinePlan &P,
458462
P.addARCSequenceOpts();
459463

460464
// Run a final round of ARC opts when ownership is enabled.
461-
if (P.getOptions().EnableOSSAModules) {
465+
if (P.getOptions().EnableOSSAModules || SILEnableLateOME) {
462466
if (!P.getOptions().DisableCopyPropagation) {
463467
P.addCopyPropagation();
464468
}
@@ -515,7 +519,7 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
515519
if (P.getOptions().StopOptimizationBeforeLoweringOwnership)
516520
return;
517521

518-
if (!P.getOptions().EnableOSSAModules)
522+
if (!P.getOptions().EnableOSSAModules && !SILEnableLateOME)
519523
P.addNonTransparentFunctionOwnershipModelEliminator();
520524

521525
// Start by linking in referenced functions from other modules.
@@ -811,7 +815,7 @@ SILPassPipelinePlan::getPerformancePassPipeline(const SILOptions &Options) {
811815

812816
// Run one last copy propagation/semantic arc opts run before serialization/us
813817
// lowering ownership.
814-
if (P.getOptions().EnableOSSAModules) {
818+
if (P.getOptions().EnableOSSAModules || SILEnableLateOME) {
815819
if (!P.getOptions().DisableCopyPropagation) {
816820
P.addCopyPropagation();
817821
}

0 commit comments

Comments
 (0)