@@ -55,6 +55,12 @@ static llvm::cl::opt<bool> SILViewSILGenCFG(
55
55
" sil-view-silgen-cfg" , llvm::cl::init(false ),
56
56
llvm::cl::desc(" Enable the sil cfg viewer pass before diagnostics" ));
57
57
58
+
59
+ llvm::cl::opt<bool > SILDisableLateOMEByDefault (
60
+ " sil-disable-late-ome-by-default" , llvm::cl::init(false ),
61
+ llvm::cl::desc(
62
+ " Disable late OME for non-transparent functions by default" ));
63
+
58
64
// ===----------------------------------------------------------------------===//
59
65
// Diagnostic Pass Pipeline
60
66
// ===----------------------------------------------------------------------===//
@@ -518,18 +524,12 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
518
524
// not blocked by any other passes' optimizations, so do it early.
519
525
P.addDifferentiabilityWitnessDevirtualizer ();
520
526
521
- // Strip ownership from non-transparent functions when we are not compiling
522
- // the stdlib module. When compiling the stdlib, we eliminate ownership on
523
- // these functions later with a nromal call to
524
- // P.addNonTransparentFunctionOwnershipModelEliminator().
525
- //
526
- // This is done so we can push ownership through the pass pipeline first for
527
- // the stdlib and then everything else.
528
- if (P.getOptions ().StopOptimizationBeforeLoweringOwnership )
529
- return ;
527
+ if (!P.getOptions ().EnableOSSAModules && SILDisableLateOMEByDefault) {
528
+ if (P.getOptions ().StopOptimizationBeforeLoweringOwnership )
529
+ return ;
530
530
531
- if (!P.getOptions ().EnableOSSAModules )
532
531
P.addNonTransparentFunctionOwnershipModelEliminator ();
532
+ }
533
533
534
534
// Start by linking in referenced functions from other modules.
535
535
P.addPerformanceSILLinker ();
@@ -543,6 +543,13 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
543
543
// optimization.
544
544
P.addGlobalOpt ();
545
545
546
+ if (!P.getOptions ().EnableOSSAModules && !SILDisableLateOMEByDefault) {
547
+ if (P.getOptions ().StopOptimizationBeforeLoweringOwnership )
548
+ return ;
549
+
550
+ P.addNonTransparentFunctionOwnershipModelEliminator ();
551
+ }
552
+
546
553
// Add the outliner pass (Osize).
547
554
P.addOutliner ();
548
555
0 commit comments