Skip to content

Commit e63a68d

Browse files
committed
Add a flag to disable late non-transparent OME when -enable-ossa-modules is turned off
Since we are now moving non-transparent OME down the pipeline by default, add a flag to turn off this behaviour. When turned on, non-transparent OME will run early, just before PerformanceSILLinker.
1 parent c9d124c commit e63a68d

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ static llvm::cl::opt<bool> SILViewSILGenCFG(
5555
"sil-view-silgen-cfg", llvm::cl::init(false),
5656
llvm::cl::desc("Enable the sil cfg viewer pass before diagnostics"));
5757

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+
5864
//===----------------------------------------------------------------------===//
5965
// Diagnostic Pass Pipeline
6066
//===----------------------------------------------------------------------===//
@@ -518,6 +524,13 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
518524
// not blocked by any other passes' optimizations, so do it early.
519525
P.addDifferentiabilityWitnessDevirtualizer();
520526

527+
if (!P.getOptions().EnableOSSAModules && SILDisableLateOMEByDefault) {
528+
if (P.getOptions().StopOptimizationBeforeLoweringOwnership)
529+
return;
530+
531+
P.addNonTransparentFunctionOwnershipModelEliminator();
532+
}
533+
521534
// Start by linking in referenced functions from other modules.
522535
P.addPerformanceSILLinker();
523536

@@ -530,18 +543,12 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
530543
// optimization.
531544
P.addGlobalOpt();
532545

533-
// Strip ownership from non-transparent functions when we are not compiling
534-
// the stdlib module. When compiling the stdlib, we eliminate ownership on
535-
// these functions later with a nromal call to
536-
// P.addNonTransparentFunctionOwnershipModelEliminator().
537-
//
538-
// This is done so we can push ownership through the pass pipeline first for
539-
// the stdlib and then everything else.
540-
if (P.getOptions().StopOptimizationBeforeLoweringOwnership)
541-
return;
546+
if (!P.getOptions().EnableOSSAModules && !SILDisableLateOMEByDefault) {
547+
if (P.getOptions().StopOptimizationBeforeLoweringOwnership)
548+
return;
542549

543-
if (!P.getOptions().EnableOSSAModules)
544550
P.addNonTransparentFunctionOwnershipModelEliminator();
551+
}
545552

546553
// Add the outliner pass (Osize).
547554
P.addOutliner();

0 commit comments

Comments
 (0)