Skip to content

Commit ea56a63

Browse files
authored
Merge pull request #28339 from drodriguez/android-sort-sil-output
[test] Use -emit-sorted-sil and reorder CHECKs to match output.
2 parents 827d319 + b17788f commit ea56a63

File tree

1 file changed

+141
-136
lines changed

1 file changed

+141
-136
lines changed

test/Frontend/skip-non-inlinable-function-bodies.swift

Lines changed: 141 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// 2. Emit the SIL for a module and check it against the expected strings in function bodies.
1010
// If we're doing the right skipping, then the strings that are CHECK-NOT'd won't have been typechecked or SILGen'd.
1111

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
1313

1414
// 3. Emit the module interface while skipping non-inlinable function bodies. Check it against the same set of strings.
1515

@@ -29,220 +29,225 @@
2929
@inline(never)
3030
func _blackHole(_ s: String) {}
3131

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+
32130
public struct Struct {
131+
@inlinable public var inlinableVar: Int {
132+
_blackHole("@inlinable getter body") // CHECK: "@inlinable getter body"
133+
return 0
134+
}
135+
33136
@inlinable public func inlinableFunc() {
34-
_blackHole("@inlinable method body") // CHECK: @inlinable method body
137+
_blackHole("@inlinable method body") // CHECK: "@inlinable method body"
35138
}
36139

37140
@inline(__always)
38141
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+
}
40155
}
41156

42157
@_transparent
43158
public func transparentFunc() {
44-
_blackHole("@_transparent method body") // CHECK: @_transparent method body
159+
_blackHole("@_transparent method body") // CHECK: "@_transparent method body"
45160
}
46161

47162
func internalFunc() {
48-
_blackHole("internal method body") // CHECK-NOT: internal method body
163+
_blackHole("internal method body") // CHECK-NOT: "internal method body"
49164
}
50165

51166
public func publicFunc() {
52-
_blackHole("public method body") // CHECK-NOT: public method body
167+
_blackHole("public method body") // CHECK-NOT: "public method body"
53168
}
54169

55170
private func privateFunc() {
56-
_blackHole("private method body") // CHECK-NOT: private method body
171+
_blackHole("private method body") // CHECK-NOT: "private method body"
57172
}
58173

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"
61176
}
62177

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"
65180
}
66181

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"
69184
}
70185

71186
init(c: Int) {
72-
_blackHole("internal init body") // CHECK-NOT: internal init body
187+
_blackHole("internal init body") // CHECK-NOT: "internal init body"
73188
}
74189

75190
public init(d: Int) {
76-
_blackHole("public init body") // CHECK-NOT: public init body
191+
_blackHole("public init body") // CHECK-NOT: "public init body"
77192
}
78193

79194
private init(e: Int) {
80-
_blackHole("private init body") // CHECK-NOT: private init body
195+
_blackHole("private init body") // CHECK-NOT: "private init body"
81196
}
82197

83198
@inlinable public subscript() -> Int {
84-
_blackHole("@inlinable subscript getter") // CHECK: @inlinable subscript getter
199+
_blackHole("@inlinable subscript getter") // CHECK: "@inlinable subscript getter"
85200
return 0
86201
}
87202

88203
@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"
90205
return 0
91206
}
92207

93208
public subscript(a: Int, b: Int, c: Int) -> Int {
94209
@_transparent get {
95-
_blackHole("@_transparent subscript getter") // CHECK: @_transparent subscript getter
210+
_blackHole("@_transparent subscript getter") // CHECK: "@_transparent subscript getter"
96211
return 0
97212
}
98213
}
99214

100215
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"
102217
return 0
103218
}
104219

105220
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"
107222
return 0
108223
}
109224

110225
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"
117227
return 0
118228
}
119229

120230
@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"
127232
return 0
128233
}
129234

130235
public var publicVar: Int {
131-
_blackHole("public getter body") // CHECK-NOT: public getter body
236+
_blackHole("public getter body") // CHECK-NOT: "public getter body"
132237
return 0
133238
}
134239

135-
public var inlinableSetter: Int {
136-
get { 0 }
137-
@inlinable set {
138-
_blackHole("@inlinable setter body") // CHECK: @inlinable setter body
139-
}
140-
}
141-
142240
public var inlineAlwaysSetter: Int {
143241
get { 0 }
144242
@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"
146244
}
147245
}
148246

149247
public var regularSetter: Int {
150248
get { 0 }
151249
set {
152-
_blackHole("@inline(__always) setter body") // CHECK-NOT: regular setter body
250+
_blackHole("@inline(__always) setter body") // CHECK-NOT: "regular setter body"
153251
}
154252
}
155253
}
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

Comments
 (0)