Skip to content

Commit 0714624

Browse files
committed
Add a source-level optimizer test for addressable dependencies.
(cherry picked from commit 5914369)
1 parent 9222b91 commit 0714624

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %target-swift-frontend -emit-sil -parse-as-library -O -module-name=test \
2+
// RUN: -enable-experimental-feature LifetimeDependence \
3+
// RUN: -enable-experimental-feature AddressableTypes \
4+
// RUN: %s | %FileCheck %s
5+
6+
// REQUIRES: swift_feature_AddressableTypes
7+
// REQUIRES: swift_feature_LifetimeDependence
8+
9+
// Enable this test as soon as CollectionOfOne is marked @_addressableForDependencies.
10+
// REQUIRES: rdar145687827
11+
12+
// CHECK-LABEL: sil {{.*}}@$s4test0A10OneIntSpan1cs0D0VySiGs012CollectionOfB0VySiG_tF : $@convention(thin) (@in_guaranteed CollectionOfOne<Int>) -> @lifetime(borrow address_for_deps 0) @owned Span<Int> {
13+
// CHECK: bb0(%0 : $*CollectionOfOne<Int>):
14+
// CHECK: [[RP:%.*]] = address_to_pointer {{.*}}%0 to $Builtin.RawPointer
15+
// CHECK: [[UP:%.*]] = struct $UnsafeRawPointer ([[RP]])
16+
// CHECK: [[OP:%.*]] = enum $Optional<UnsafeRawPointer>, #Optional.some!enumelt, [[UP]]
17+
// CHECK: [[SPAN:%.*]] = struct $Span<Int> ([[OP]]
18+
// CHECK: return [[SPAN]]
19+
// CHECK-LABEL: } // end sil function '$s4test0A10OneIntSpan1cs0D0VySiGs012CollectionOfB0VySiG_tF'
20+
@available(SwiftStdlib 6.2, *)
21+
@lifetime(borrow c)
22+
public func testOneIntSpan(c: CollectionOfOne<Int>) -> Span<Int> {
23+
c.span
24+
}

0 commit comments

Comments
 (0)