Skip to content

Enable late OME via an experimental flag #39363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/SILOptimizer/PassManager/PassPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ static llvm::cl::opt<bool> SILViewSILGenCFG(
"sil-view-silgen-cfg", llvm::cl::init(false),
llvm::cl::desc("Enable the sil cfg viewer pass before diagnostics"));

static llvm::cl::opt<bool>
SILEnableLateOME("sil-enable-late-ome", llvm::cl::init(false),
llvm::cl::desc("Enable late OwnershipModel elimination"));

//===----------------------------------------------------------------------===//
// Diagnostic Pass Pipeline
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -365,7 +369,7 @@ void addFunctionPasses(SILPassPipelinePlan &P,
P.addDevirtualizer();
P.addARCSequenceOpts();

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

// Clean up Semantic ARC before we perform additional post-inliner opts.
if (P.getOptions().EnableOSSAModules) {
if (P.getOptions().EnableOSSAModules || SILEnableLateOME) {
if (!P.getOptions().DisableCopyPropagation) {
P.addCopyPropagation();
}
Expand Down Expand Up @@ -458,7 +462,7 @@ void addFunctionPasses(SILPassPipelinePlan &P,
P.addARCSequenceOpts();

// Run a final round of ARC opts when ownership is enabled.
if (P.getOptions().EnableOSSAModules) {
if (P.getOptions().EnableOSSAModules || SILEnableLateOME) {
if (!P.getOptions().DisableCopyPropagation) {
P.addCopyPropagation();
}
Expand Down Expand Up @@ -515,7 +519,7 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
if (P.getOptions().StopOptimizationBeforeLoweringOwnership)
return;

if (!P.getOptions().EnableOSSAModules)
if (!P.getOptions().EnableOSSAModules && !SILEnableLateOME)
P.addNonTransparentFunctionOwnershipModelEliminator();

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

// Run one last copy propagation/semantic arc opts run before serialization/us
// lowering ownership.
if (P.getOptions().EnableOSSAModules) {
if (P.getOptions().EnableOSSAModules || SILEnableLateOME) {
if (!P.getOptions().DisableCopyPropagation) {
P.addCopyPropagation();
}
Expand Down