Skip to content

Add OSSA ARC opts before lowering to non-ossa #68446

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
24 changes: 7 additions & 17 deletions lib/SILOptimizer/PassManager/PassPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ 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"));


llvm::cl::opt<bool> SILDisableLateOMEByDefault(
"sil-disable-late-ome-by-default", llvm::cl::init(false),
llvm::cl::desc(
"Disable late OME for non-transparent functions by default"));

llvm::cl::opt<bool>
EnableDestroyHoisting("enable-destroy-hoisting", llvm::cl::init(false),
llvm::cl::desc("Enable the DestroyHoisting pass."));
Expand Down Expand Up @@ -427,7 +421,13 @@ void addFunctionPasses(SILPassPipelinePlan &P,
// Cleanup, which is important if the inliner has restarted the pass pipeline.
P.addPerformanceConstantPropagation();

if (!P.getOptions().EnableOSSAModules && !SILDisableLateOMEByDefault) {
if (!P.getOptions().EnableOSSAModules) {
// Last chance to run ossa opts, run them here before lowering to non-ossa.
if (P.getOptions().CopyPropagation == CopyPropagationOption::On) {
P.addComputeSideEffects();
P.addCopyPropagation();
}
P.addSemanticARCOpts();
if (P.getOptions().StopOptimizationBeforeLoweringOwnership)
return;

Expand Down Expand Up @@ -610,16 +610,6 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
// not blocked by any other passes' optimizations, so do it early.
P.addDifferentiabilityWitnessDevirtualizer();

if (!P.getOptions().EnableOSSAModules && SILDisableLateOMEByDefault) {
if (P.getOptions().StopOptimizationBeforeLoweringOwnership)
return;

if (SILPrintFinalOSSAModule) {
addModulePrinterPipeline(P, "SIL Print Final OSSA Module");
}
P.addNonTransparentFunctionOwnershipModelEliminator();
}

// Start by linking in referenced functions from other modules.
P.addPerformanceSILLinker();

Expand Down
3 changes: 1 addition & 2 deletions test/SILOptimizer/consuming_parameter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ public func async_dead_arg_call(o: consuming AnyObject) async {

// CHECK-LABEL: sil [ossa] @async_dead_arg_call_lexical : {{.*}} {
// CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : @noImplicitCopy @_lexical @owned
// CHECK: [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]]
// CHECK: [[EXECUTOR:%[^,]+]] = enum $Optional<Builtin.Executor>, #Optional.none!enumelt
// CHECK: [[CALLEE:%[^,]+]] = function_ref @async_callee
// CHECK: apply [[CALLEE]]()
// CHECK: hop_to_executor [[EXECUTOR]]
// CHECK: destroy_value [[MOVE]]
// CHECK: destroy_value [[INSTANCE]]
// CHECK-LABEL: } // end sil function 'async_dead_arg_call_lexical'
@_silgen_name("async_dead_arg_call_lexical")
public func async_dead_arg_call_lexical(@_noEagerMove o: consuming AnyObject) async {
Expand Down
2 changes: 0 additions & 2 deletions test/stdlib/move_function.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ tests.test("simpleVarTest") {
expectTrue(_isUnique_native(&x))

var y = x
expectFalse(_isUnique_native(&x))
let _ = consume y
expectTrue(_isUnique_native(&x))
y = Klass()
Expand All @@ -101,7 +100,6 @@ tests.test("simpleVarTest") {
tests.test("simpleInoutVarTest") {
func inOutTest(_ x: inout Klass) {
var y = x
expectFalse(_isUnique_native(&x))
let _ = consume y
expectTrue(_isUnique_native(&x))
y = Klass()
Expand Down