@@ -51,6 +51,10 @@ static llvm::cl::opt<bool> SILViewSILGenCFG(
51
51
" sil-view-silgen-cfg" , llvm::cl::init(false ),
52
52
llvm::cl::desc(" Enable the sil cfg viewer pass before diagnostics" ));
53
53
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
+
54
58
// ===----------------------------------------------------------------------===//
55
59
// Diagnostic Pass Pipeline
56
60
// ===----------------------------------------------------------------------===//
@@ -365,7 +369,7 @@ void addFunctionPasses(SILPassPipelinePlan &P,
365
369
P.addDevirtualizer ();
366
370
P.addARCSequenceOpts ();
367
371
368
- if (P.getOptions ().EnableOSSAModules ) {
372
+ if (P.getOptions ().EnableOSSAModules || SILEnableLateOME ) {
369
373
// We earlier eliminated ownership if we are not compiling the stdlib. Now
370
374
// handle the stdlib functions, re-simplifying, eliminating ARC as we do.
371
375
if (!P.getOptions ().DisableCopyPropagation ) {
@@ -391,7 +395,7 @@ void addFunctionPasses(SILPassPipelinePlan &P,
391
395
}
392
396
393
397
// Clean up Semantic ARC before we perform additional post-inliner opts.
394
- if (P.getOptions ().EnableOSSAModules ) {
398
+ if (P.getOptions ().EnableOSSAModules || SILEnableLateOME ) {
395
399
if (!P.getOptions ().DisableCopyPropagation ) {
396
400
P.addCopyPropagation ();
397
401
}
@@ -458,7 +462,7 @@ void addFunctionPasses(SILPassPipelinePlan &P,
458
462
P.addARCSequenceOpts ();
459
463
460
464
// Run a final round of ARC opts when ownership is enabled.
461
- if (P.getOptions ().EnableOSSAModules ) {
465
+ if (P.getOptions ().EnableOSSAModules || SILEnableLateOME ) {
462
466
if (!P.getOptions ().DisableCopyPropagation ) {
463
467
P.addCopyPropagation ();
464
468
}
@@ -515,7 +519,7 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
515
519
if (P.getOptions ().StopOptimizationBeforeLoweringOwnership )
516
520
return ;
517
521
518
- if (!P.getOptions ().EnableOSSAModules )
522
+ if (!P.getOptions ().EnableOSSAModules && !SILEnableLateOME )
519
523
P.addNonTransparentFunctionOwnershipModelEliminator ();
520
524
521
525
// Start by linking in referenced functions from other modules.
@@ -811,7 +815,7 @@ SILPassPipelinePlan::getPerformancePassPipeline(const SILOptions &Options) {
811
815
812
816
// Run one last copy propagation/semantic arc opts run before serialization/us
813
817
// lowering ownership.
814
- if (P.getOptions ().EnableOSSAModules ) {
818
+ if (P.getOptions ().EnableOSSAModules || SILEnableLateOME ) {
815
819
if (!P.getOptions ().DisableCopyPropagation ) {
816
820
P.addCopyPropagation ();
817
821
}
0 commit comments