File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
validation-test/SILOptimizer Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %target-run-simple-swift | %FileCheck %s
2
+
3
+ // REQUIRES: executable_test
4
+ // REQUIRES: optimized_stdlib
5
+ // REQUIRES: swift_test_mode_optimize
6
+
7
+ struct Consumer {
8
+ let store : [ Int ]
9
+ @inline ( __always)
10
+ init ( _ x: [ Int ] ) {
11
+ var y = x
12
+ y [ 0 ] = 42
13
+ store = y
14
+ }
15
+ }
16
+
17
+ typealias PInt = UnsafePointer < Int >
18
+ @inline ( never)
19
+ func baseAddress( _ a: PInt ) -> PInt { a }
20
+
21
+ extension Optional {
22
+ @inline ( __always)
23
+ mutating func release( ) -> Wrapped {
24
+ defer { self = nil }
25
+ return self !
26
+ }
27
+ }
28
+
29
+ @inline ( never)
30
+ func main( _ a: inout [ Int ] ? ) -> [ Int ] {
31
+ let x = a. release ( )
32
+ let r = Consumer ( x) . store
33
+ return r
34
+ }
35
+
36
+ func test( ) {
37
+ var a = Optional ( Array ( 0 ... 3 ) )
38
+ let b0 = baseAddress ( a!)
39
+ let b = main ( & a)
40
+ let b1 = baseAddress ( b)
41
+ // CHECK: true
42
+ print ( b0 == b1)
43
+ // CHECK: nil [42, 1, 2, 3]
44
+ print ( a as Any , b)
45
+ }
46
+
47
+ test ( )
48
+
You can’t perform that action at this time.
0 commit comments