mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The pass is already not being run during normal compilation scenarios today since it bails on OSSA except in certain bit-rot situations where a test wasn't updated and so was inadvertently invoking the pass. I discovered these while originally just trying to eliminate the pass from the diagnostic pipeline. The reason why I am doing this in one larger change is that I found there were a bunch of sil tests inadvertently relying on guaranteed arc opts to eliminate copy traffic. So, if I just removed this and did this in two steps, I would basically be unoptimizing then re-optimizing the tests. Some notes: 1. The new guaranteed arc opts is based off of SemanticARCOpts and runs only on ossa. Specifically, in this new pass, we just perform simple canonicalizations that do not involve any significant analysis. Some examples: a copy_value all of whose uses are destroys. This will do what the original pass did and more without more compile time. I did a conservative first approximation, but we can probably tune this a bit. 2. the reason why I am doing this now is that I was trying to eliminate the enable-ownership-stripping-after-serialization flag and discovered that the test opaque_value_mandatory implicitly depends on this since sil-opt by default was the only place left in the compiler with that option set to false by default. So I am eliminating that dependency before I land the larger change.
25 lines
876 B
Plaintext
25 lines
876 B
Plaintext
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-runtime %s
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
|
|
sil @anyobject_user : $@convention(thin) (@guaranteed Builtin.AnyObject) -> ()
|
|
|
|
// CHECK-LABEL: @retain_release_unknown_object
|
|
sil [ossa] @retain_release_unknown_object : $@convention(thin) (@guaranteed Builtin.AnyObject) -> () {
|
|
entry(%x : @guaranteed $Builtin.AnyObject):
|
|
// CHECK-native: swift_retain
|
|
// CHECK-objc: swift_unknownObjectRetain
|
|
%y = copy_value %x : $Builtin.AnyObject
|
|
br bb1
|
|
|
|
bb1:
|
|
%func = function_ref @anyobject_user : $@convention(thin) (@guaranteed Builtin.AnyObject) -> ()
|
|
apply %func(%y) : $@convention(thin) (@guaranteed Builtin.AnyObject) -> ()
|
|
// CHECK-native: swift_release
|
|
// CHECK-objc: swift_unknownObjectRelease
|
|
destroy_value %y : $Builtin.AnyObject
|
|
return undef : $()
|
|
}
|