|
9 | 9 | // 2. Emit the SIL for a module and check it against the expected strings in function bodies.
|
10 | 10 | // If we're doing the right skipping, then the strings that are CHECK-NOT'd won't have been typechecked or SILGen'd.
|
11 | 11 |
|
12 |
| -// RUN: %target-swift-frontend -emit-sil -O -experimental-skip-non-inlinable-function-bodies %s 2>&1 | %FileCheck %s --check-prefixes CHECK,CHECK-SIL-ONLY |
| 12 | +// RUN: %target-swift-frontend -emit-sil -O -experimental-skip-non-inlinable-function-bodies -emit-sorted-sil %s 2>&1 | %FileCheck %s --check-prefixes CHECK,CHECK-SIL-ONLY |
13 | 13 |
|
14 | 14 | // 3. Emit the module interface while skipping non-inlinable function bodies. Check it against the same set of strings.
|
15 | 15 |
|
|
29 | 29 | @inline(never)
|
30 | 30 | func _blackHole(_ s: String) {}
|
31 | 31 |
|
| 32 | +// NOTE: The order of the checks below is important. The checks try to be |
| 33 | +// logically grouped, but sometimes -emit-sorted-sil needs to break the logical |
| 34 | +// order. |
| 35 | + |
| 36 | +@inlinable public func inlinableFunc() { |
| 37 | + _blackHole("@inlinable func body") // CHECK: "@inlinable func body" |
| 38 | +} |
| 39 | + |
| 40 | +@_fixed_layout |
| 41 | +public class InlinableDeinit { |
| 42 | + @inlinable deinit { |
| 43 | + _blackHole("@inlinable deinit body") // CHECK: "@inlinable deinit body" |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +@_fixed_layout |
| 48 | +public class InlineAlwaysDeinit { |
| 49 | + @inline(__always) deinit { |
| 50 | + _blackHole("@inline(__always) deinit body") // CHECK-NOT: "@inline(__always) deinit body" |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +public class NormalDeinit { |
| 55 | + deinit { |
| 56 | + _blackHole("regular deinit body") // CHECK-NOT: "regular deinit body" |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +@_transparent public func transparentFunc() { |
| 61 | + _blackHole("@_transparent func body") // CHECK: "@_transparent func body" |
| 62 | +} |
| 63 | + |
| 64 | +@inline(__always) public func inlineAlwaysFunc() { |
| 65 | + _blackHole("@inline(__always) func body") // CHECK-NOT: "@inline(__always) func body" |
| 66 | +} |
| 67 | + |
| 68 | +func internalFunc() { |
| 69 | + _blackHole("internal func body") // CHECK-NOT: "internal func body" |
| 70 | +} |
| 71 | + |
| 72 | +public func publicFunc() { |
| 73 | + _blackHole("public func body") // CHECK-NOT: "public func body" |
| 74 | +} |
| 75 | + |
| 76 | +private func privateFunc() { |
| 77 | + _blackHole("private func body") // CHECK-NOT: "private func body" |
| 78 | +} |
| 79 | + |
| 80 | +@inline(__always) public func inlineAlwaysLocalTypeFunc() { |
| 81 | + typealias InlineAlwaysLocalType = Int |
| 82 | + _blackHole("@inline(__always) func body with local type") // CHECK-NOT: "@inline(__always) func body with local type" |
| 83 | + func takesInlineAlwaysLocalType(_ x: InlineAlwaysLocalType) { |
| 84 | + _blackHole("nested func body inside @inline(__always) func body taking local type") // CHECK-NOT: "nested func body inside @inline(__always) func body taking local type" |
| 85 | + } |
| 86 | + takesInlineAlwaysLocalType(0) |
| 87 | +} |
| 88 | + |
| 89 | +public func publicLocalTypeFunc() { |
| 90 | + typealias LocalType = Int |
| 91 | + _blackHole("public func body with local type") // CHECK-NOT: "public func body with local type" |
| 92 | + func takesLocalType(_ x: LocalType) { |
| 93 | + _blackHole("nested func body inside public func body taking local type") // CHECK-NOT: "nested func body inside public func body taking local type" |
| 94 | + } |
| 95 | + takesLocalType(0) |
| 96 | +} |
| 97 | + |
| 98 | +@inlinable |
| 99 | +public func inlinableLocalTypeFunc() { |
| 100 | + typealias InlinableLocalType = Int |
| 101 | + _blackHole("@inlinable func body with local type") // CHECK: "@inlinable func body with local type" |
| 102 | + func takesInlinableLocalType(_ x: InlinableLocalType) { |
| 103 | + _blackHole("nested func body inside @inlinable func body taking local type") // CHECK: "nested func body inside @inlinable func body taking local type" |
| 104 | + } |
| 105 | + takesInlinableLocalType(0) |
| 106 | +} |
| 107 | + |
| 108 | +@_transparent public func _transparentLocalTypeFunc() { |
| 109 | + typealias TransparentLocalType = Int |
| 110 | + _blackHole("@_transparent func body with local type") // CHECK: "@_transparent func body with local type" |
| 111 | + func takesTransparentLocalType(_ x: TransparentLocalType) { |
| 112 | + _blackHole("nested func body inside @_transparent func body taking local type") // CHECK: "nested func body inside @_transparent func body taking local type" |
| 113 | + } |
| 114 | + takesTransparentLocalType(0) |
| 115 | +} |
| 116 | + |
| 117 | +@inlinable |
| 118 | +public func inlinableNestedLocalTypeFunc() { |
| 119 | + func nestedFunc() { |
| 120 | + _blackHole("nested func body inside @inlinable func body") // CHECK: "nested func body inside @inlinable func body" |
| 121 | + typealias InlinableNestedLocalType = Int |
| 122 | + func takesLocalType(_ x: InlinableNestedLocalType) { |
| 123 | + _blackHole("nested func body inside @inlinable func body taking local type") // CHECK: "nested func body inside @inlinable func body taking local type" |
| 124 | + } |
| 125 | + takesLocalType(0) |
| 126 | + } |
| 127 | + nestedFunc() |
| 128 | +} |
| 129 | + |
32 | 130 | public struct Struct {
|
| 131 | + @inlinable public var inlinableVar: Int { |
| 132 | + _blackHole("@inlinable getter body") // CHECK: "@inlinable getter body" |
| 133 | + return 0 |
| 134 | + } |
| 135 | + |
33 | 136 | @inlinable public func inlinableFunc() {
|
34 |
| - _blackHole("@inlinable method body") // CHECK: @inlinable method body |
| 137 | + _blackHole("@inlinable method body") // CHECK: "@inlinable method body" |
35 | 138 | }
|
36 | 139 |
|
37 | 140 | @inline(__always)
|
38 | 141 | public func inlineAlwaysFunc() {
|
39 |
| - _blackHole("@inline(__always) method body") // CHECK-NOT: @inline(__always) method body |
| 142 | + _blackHole("@inline(__always) method body") // CHECK-NOT: "@inline(__always) method body" |
| 143 | + } |
| 144 | + |
| 145 | + @_transparent public var transparentVar: Int { |
| 146 | + _blackHole("@_transparent getter body") // CHECK: "@_transparent getter body" |
| 147 | + return 0 |
| 148 | + } |
| 149 | + |
| 150 | + public var inlinableSetter: Int { |
| 151 | + get { 0 } |
| 152 | + @inlinable set { |
| 153 | + _blackHole("@inlinable setter body") // CHECK: "@inlinable setter body" |
| 154 | + } |
40 | 155 | }
|
41 | 156 |
|
42 | 157 | @_transparent
|
43 | 158 | public func transparentFunc() {
|
44 |
| - _blackHole("@_transparent method body") // CHECK: @_transparent method body |
| 159 | + _blackHole("@_transparent method body") // CHECK: "@_transparent method body" |
45 | 160 | }
|
46 | 161 |
|
47 | 162 | func internalFunc() {
|
48 |
| - _blackHole("internal method body") // CHECK-NOT: internal method body |
| 163 | + _blackHole("internal method body") // CHECK-NOT: "internal method body" |
49 | 164 | }
|
50 | 165 |
|
51 | 166 | public func publicFunc() {
|
52 |
| - _blackHole("public method body") // CHECK-NOT: public method body |
| 167 | + _blackHole("public method body") // CHECK-NOT: "public method body" |
53 | 168 | }
|
54 | 169 |
|
55 | 170 | private func privateFunc() {
|
56 |
| - _blackHole("private method body") // CHECK-NOT: private method body |
| 171 | + _blackHole("private method body") // CHECK-NOT: "private method body" |
57 | 172 | }
|
58 | 173 |
|
59 |
| - @inlinable public init() { |
60 |
| - _blackHole("@inlinable init body") // CHECK: @inlinable init body |
| 174 | + @_transparent public init(b: Int) { |
| 175 | + _blackHole("@_transparent init body") // CHECK: "@_transparent init body" |
61 | 176 | }
|
62 | 177 |
|
63 |
| - @inline(__always) public init(a: Int) { |
64 |
| - _blackHole("@inline(__always) init body") // CHECK-NOT: @inline(__always) init body |
| 178 | + @inlinable public init() { |
| 179 | + _blackHole("@inlinable init body") // CHECK: "@inlinable init body" |
65 | 180 | }
|
66 | 181 |
|
67 |
| - @_transparent public init(b: Int) { |
68 |
| - _blackHole("@_transparent init body") // CHECK: @_transparent init body |
| 182 | + @inline(__always) public init(a: Int) { |
| 183 | + _blackHole("@inline(__always) init body") // CHECK-NOT: "@inline(__always) init body" |
69 | 184 | }
|
70 | 185 |
|
71 | 186 | init(c: Int) {
|
72 |
| - _blackHole("internal init body") // CHECK-NOT: internal init body |
| 187 | + _blackHole("internal init body") // CHECK-NOT: "internal init body" |
73 | 188 | }
|
74 | 189 |
|
75 | 190 | public init(d: Int) {
|
76 |
| - _blackHole("public init body") // CHECK-NOT: public init body |
| 191 | + _blackHole("public init body") // CHECK-NOT: "public init body" |
77 | 192 | }
|
78 | 193 |
|
79 | 194 | private init(e: Int) {
|
80 |
| - _blackHole("private init body") // CHECK-NOT: private init body |
| 195 | + _blackHole("private init body") // CHECK-NOT: "private init body" |
81 | 196 | }
|
82 | 197 |
|
83 | 198 | @inlinable public subscript() -> Int {
|
84 |
| - _blackHole("@inlinable subscript getter") // CHECK: @inlinable subscript getter |
| 199 | + _blackHole("@inlinable subscript getter") // CHECK: "@inlinable subscript getter" |
85 | 200 | return 0
|
86 | 201 | }
|
87 | 202 |
|
88 | 203 | @inline(__always) public subscript(a: Int, b: Int) -> Int {
|
89 |
| - _blackHole("@inline(__always) subscript getter") // CHECK-NOT: @inline(__always) subscript getter |
| 204 | + _blackHole("@inline(__always) subscript getter") // CHECK-NOT: "@inline(__always) subscript getter" |
90 | 205 | return 0
|
91 | 206 | }
|
92 | 207 |
|
93 | 208 | public subscript(a: Int, b: Int, c: Int) -> Int {
|
94 | 209 | @_transparent get {
|
95 |
| - _blackHole("@_transparent subscript getter") // CHECK: @_transparent subscript getter |
| 210 | + _blackHole("@_transparent subscript getter") // CHECK: "@_transparent subscript getter" |
96 | 211 | return 0
|
97 | 212 | }
|
98 | 213 | }
|
99 | 214 |
|
100 | 215 | subscript(a: Int, b: Int, c: Int, d: Int) -> Int {
|
101 |
| - _blackHole("internal subscript getter") // CHECK-NOT: internal subscript getter |
| 216 | + _blackHole("internal subscript getter") // CHECK-NOT: "internal subscript getter" |
102 | 217 | return 0
|
103 | 218 | }
|
104 | 219 |
|
105 | 220 | public subscript(a: Int, b: Int, c: Int, d: Int, e: Int) -> Int {
|
106 |
| - _blackHole("public subscript getter") // CHECK-NOT: public subscript getter |
| 221 | + _blackHole("public subscript getter") // CHECK-NOT: "public subscript getter" |
107 | 222 | return 0
|
108 | 223 | }
|
109 | 224 |
|
110 | 225 | private subscript(e: Int) -> Int {
|
111 |
| - _blackHole("private subscript getter") // CHECK-NOT: private subscript getter |
112 |
| - return 0 |
113 |
| - } |
114 |
| - |
115 |
| - @inlinable public var inlinableVar: Int { |
116 |
| - _blackHole("@inlinable getter body") // CHECK: @inlinable getter body |
| 226 | + _blackHole("private subscript getter") // CHECK-NOT: "private subscript getter" |
117 | 227 | return 0
|
118 | 228 | }
|
119 | 229 |
|
120 | 230 | @inline(__always) public var inlineAlwaysVar: Int {
|
121 |
| - _blackHole("@inline(__always) getter body") // CHECK-NOT: @inline(__always) getter body |
122 |
| - return 0 |
123 |
| - } |
124 |
| - |
125 |
| - @_transparent public var transparentVar: Int { |
126 |
| - _blackHole("@_transparent getter body") // CHECK: @_transparent getter body |
| 231 | + _blackHole("@inline(__always) getter body") // CHECK-NOT: "@inline(__always) getter body" |
127 | 232 | return 0
|
128 | 233 | }
|
129 | 234 |
|
130 | 235 | public var publicVar: Int {
|
131 |
| - _blackHole("public getter body") // CHECK-NOT: public getter body |
| 236 | + _blackHole("public getter body") // CHECK-NOT: "public getter body" |
132 | 237 | return 0
|
133 | 238 | }
|
134 | 239 |
|
135 |
| - public var inlinableSetter: Int { |
136 |
| - get { 0 } |
137 |
| - @inlinable set { |
138 |
| - _blackHole("@inlinable setter body") // CHECK: @inlinable setter body |
139 |
| - } |
140 |
| - } |
141 |
| - |
142 | 240 | public var inlineAlwaysSetter: Int {
|
143 | 241 | get { 0 }
|
144 | 242 | @inline(__always) set {
|
145 |
| - _blackHole("@inline(__always) setter body") // CHECK-NOT: @inline(__always) setter body |
| 243 | + _blackHole("@inline(__always) setter body") // CHECK-NOT: "@inline(__always) setter body" |
146 | 244 | }
|
147 | 245 | }
|
148 | 246 |
|
149 | 247 | public var regularSetter: Int {
|
150 | 248 | get { 0 }
|
151 | 249 | set {
|
152 |
| - _blackHole("@inline(__always) setter body") // CHECK-NOT: regular setter body |
| 250 | + _blackHole("@inline(__always) setter body") // CHECK-NOT: "regular setter body" |
153 | 251 | }
|
154 | 252 | }
|
155 | 253 | }
|
156 |
| - |
157 |
| -@_fixed_layout |
158 |
| -public class InlinableDesubscript { |
159 |
| - @inlinable deinit { |
160 |
| - _blackHole("@inlinable deinit body") // CHECK: @inlinable deinit body |
161 |
| - } |
162 |
| -} |
163 |
| - |
164 |
| -@_fixed_layout |
165 |
| -public class InlineAlwaysDeinit { |
166 |
| - @inline(__always) deinit { |
167 |
| - _blackHole("@inline(__always) deinit body") // CHECK-NOT: @inline(__always) deinit body |
168 |
| - } |
169 |
| -} |
170 |
| - |
171 |
| -public class NormalDeinit { |
172 |
| - deinit { |
173 |
| - _blackHole("regular deinit body") // CHECK-NOT: regular deinit body |
174 |
| - } |
175 |
| -} |
176 |
| - |
177 |
| -@inlinable public func inlinableFunc() { |
178 |
| - _blackHole("@inlinable func body") // CHECK: @inlinable func body |
179 |
| -} |
180 |
| - |
181 |
| -@inline(__always) public func inlineAlwaysFunc() { |
182 |
| - _blackHole("@inline(__always) func body") // CHECK-NOT: @inline(__always) func body |
183 |
| -} |
184 |
| - |
185 |
| -@_transparent public func transparentFunc() { |
186 |
| - _blackHole("@_transparent func body") // CHECK: @_transparent func body |
187 |
| -} |
188 |
| - |
189 |
| -func internalFunc() { |
190 |
| - _blackHole("internal func body") // CHECK-NOT: internal func body |
191 |
| -} |
192 |
| - |
193 |
| -public func publicFunc() { |
194 |
| - _blackHole("public func body") // CHECK-NOT: public func body |
195 |
| -} |
196 |
| - |
197 |
| -private func privateFunc() { |
198 |
| - _blackHole("private func body") // CHECK-NOT: private func body |
199 |
| -} |
200 |
| - |
201 |
| -@inlinable |
202 |
| -public func inlinableLocalTypeFunc() { |
203 |
| - typealias InlinableLocalType = Int |
204 |
| - _blackHole("@inlinable func body with local type") // CHECK: @inlinable func body with local type |
205 |
| - func takesInlinableLocalType(_ x: InlinableLocalType) { |
206 |
| - _blackHole("nested func body inside @inlinable func body taking local type") // CHECK: nested func body inside @inlinable func body taking local type |
207 |
| - } |
208 |
| - takesInlinableLocalType(0) |
209 |
| -} |
210 |
| - |
211 |
| -@inline(__always) public func inlineAlwaysLocalTypeFunc() { |
212 |
| - typealias InlineAlwaysLocalType = Int |
213 |
| - _blackHole("@inline(__always) func body with local type") // CHECK-NOT: @inline(__always) func body with local type |
214 |
| - func takesInlineAlwaysLocalType(_ x: InlineAlwaysLocalType) { |
215 |
| - _blackHole("nested func body inside @inline(__always) func body taking local type") // CHECK-NOT: nested func body inside @inline(__always) func body taking local type |
216 |
| - } |
217 |
| - takesInlineAlwaysLocalType(0) |
218 |
| -} |
219 |
| - |
220 |
| -@_transparent public func _transparentLocalTypeFunc() { |
221 |
| - typealias TransparentLocalType = Int |
222 |
| - _blackHole("@_transparent func body with local type") // CHECK: @_transparent func body with local type |
223 |
| - func takesTransparentLocalType(_ x: TransparentLocalType) { |
224 |
| - _blackHole("nested func body inside @_transparent func body taking local type") // CHECK: nested func body inside @_transparent func body taking local type |
225 |
| - } |
226 |
| - takesTransparentLocalType(0) |
227 |
| -} |
228 |
| - |
229 |
| -public func publicLocalTypeFunc() { |
230 |
| - typealias LocalType = Int |
231 |
| - _blackHole("public func body with local type") // CHECK-NOT: public func body with local type |
232 |
| - func takesLocalType(_ x: LocalType) { |
233 |
| - _blackHole("nested func body inside public func body taking local type") // CHECK-NOT: nested func body inside public func body taking local type |
234 |
| - } |
235 |
| - takesLocalType(0) |
236 |
| -} |
237 |
| -@inlinable |
238 |
| -public func inlinableNestedLocalTypeFunc() { |
239 |
| - func nestedFunc() { |
240 |
| - _blackHole("nested func body inside @inlinable func body") // CHECK: nested func body inside @inlinable func body |
241 |
| - typealias InlinableNestedLocalType = Int |
242 |
| - func takesLocalType(_ x: InlinableNestedLocalType) { |
243 |
| - _blackHole("nested func body inside @inlinable func body taking local type") // CHECK: nested func body inside @inlinable func body taking local type |
244 |
| - } |
245 |
| - takesLocalType(0) |
246 |
| - } |
247 |
| - nestedFunc() |
248 |
| -} |
|
0 commit comments