From 451252d42fb758615904520ac0b3d7ff2ba052b8 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Thu, 24 Oct 2019 13:41:28 -0700 Subject: [PATCH] [sil] Add a run of ownership model eliminator in the lowering pass pipeline to ensure we eliminate ownership even if a bisecting counter has disabled the normal ome run. I also had to fix up one test and eliminated a test that did not really make sense in the first place to test with ossa. (Specifically, copy_value_destroy_value is a test I added when adding copy_value, destroy_value, it really doesn't make sense since we will just lower it to retain, release before we hit IRGen). --- lib/SILOptimizer/PassManager/PassPipeline.cpp | 1 + test/IRGen/copy_value_destroy_value.sil | 46 ------------------- test/IRGen/unknown_object.sil | 3 ++ 3 files changed, 4 insertions(+), 46 deletions(-) delete mode 100644 test/IRGen/copy_value_destroy_value.sil diff --git a/lib/SILOptimizer/PassManager/PassPipeline.cpp b/lib/SILOptimizer/PassManager/PassPipeline.cpp index 79974aaa9dbb2..cf118006bd076 100644 --- a/lib/SILOptimizer/PassManager/PassPipeline.cpp +++ b/lib/SILOptimizer/PassManager/PassPipeline.cpp @@ -575,6 +575,7 @@ SILPassPipelinePlan SILPassPipelinePlan::getLoweringPassPipeline(const SILOptions &Options) { SILPassPipelinePlan P(Options); P.startPipeline("Address Lowering"); + P.addOwnershipModelEliminator(); P.addIRGenPrepare(); P.addAddressLowering(); diff --git a/test/IRGen/copy_value_destroy_value.sil b/test/IRGen/copy_value_destroy_value.sil deleted file mode 100644 index 48bf5ef29348d..0000000000000 --- a/test/IRGen/copy_value_destroy_value.sil +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %target-swift-frontend -parse-sil -emit-ir %s | %FileCheck %s -// REQUIRES: OS=macosx - -// Make sure that we are using type lowering and that we are handling the return -// value correctly. - -sil_stage canonical - -import Builtin - -struct Foo { - var t1 : Builtin.Int32 - var c1 : Builtin.NativeObject - var t2 : Builtin.Int32 - var c2 : Builtin.NativeObject - var t3 : Builtin.Int32 -} - -// CHECK: define{{( protected)?}} swiftcc void @non_trivial( -// CHECK: [[GEP1:%.*]] = getelementptr inbounds %T019copy_value_destroy_B03FooV, %T019copy_value_destroy_B03FooV* %1, i32 0, i32 2 -// CHECK-NEXT: [[VAL1:%.*]] = load %swift.refcounted*, %swift.refcounted** [[GEP1]], align 8 -// CHECK: [[GEP2:%.*]] = getelementptr inbounds %T019copy_value_destroy_B03FooV, %T019copy_value_destroy_B03FooV* %1, i32 0, i32 5 -// CHECK-NEXT: [[VAL2:%.*]] = load %swift.refcounted*, %swift.refcounted** [[GEP2]], align 8 -// CHECK: call %swift.refcounted* @swift_retain(%swift.refcounted* returned [[VAL1]]) -// CHECK: call %swift.refcounted* @swift_retain(%swift.refcounted* returned [[VAL2]]) -// CHECK: call void @swift_release(%swift.refcounted* [[VAL1]]) -// CHECK: call void @swift_release(%swift.refcounted* [[VAL2]]) -sil [ossa] @non_trivial : $@convention(thin) (@guaranteed Foo) -> () { -bb0(%0 : @guaranteed $Foo): - %1 = copy_value %0 : $Foo - destroy_value %1 : $Foo - %2 = tuple() - return %2 : $() -} - -// CHECK: define{{( protected)?}} swiftcc void @non_trivial_unowned( -// CHECK: call %swift.refcounted* @swift_unownedRetainStrong(%swift.refcounted* returned %0) -// CHECK: call void @swift_release(%swift.refcounted* %0) -sil [ossa] @non_trivial_unowned : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () { -bb0(%0 : @guaranteed $Builtin.NativeObject): - %1 = ref_to_unowned %0 : $Builtin.NativeObject to $@sil_unowned Builtin.NativeObject - %2 = copy_unowned_value %1 : $@sil_unowned Builtin.NativeObject - destroy_value %2 : $Builtin.NativeObject - %9999 = tuple() - return %9999 : $() -} diff --git a/test/IRGen/unknown_object.sil b/test/IRGen/unknown_object.sil index b3f380d26ef26..e5e86bb1b9d7a 100644 --- a/test/IRGen/unknown_object.sil +++ b/test/IRGen/unknown_object.sil @@ -10,6 +10,9 @@ entry(%x : @guaranteed $Builtin.AnyObject): // CHECK-native: swift_retain // CHECK-objc: swift_unknownObjectRetain %y = copy_value %x : $Builtin.AnyObject + br bb1 + +bb1: // CHECK-native: swift_release // CHECK-objc: swift_unknownObjectRelease destroy_value %y : $Builtin.AnyObject