1
- // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil - emit-ir -primary-file %s -disable-objc-attr-requires-foundation-module | %FileCheck %s
1
+ // RUN: %target-swift-frontend -emit-ir -primary-file %s -disable-objc-attr-requires-foundation-module | %FileCheck %s
2
2
3
3
// REQUIRES: CPU=x86_64
4
4
// XFAIL: linux
@@ -9,7 +9,7 @@ protocol ClassBound : class {
9
9
protocol ClassBound2 : class {
10
10
func classBoundMethod2( )
11
11
}
12
- protocol ClassBoundBinary : class , ClassBound {
12
+ protocol ClassBoundBinary : ClassBound {
13
13
func classBoundBinaryMethod( _ x: Self )
14
14
}
15
15
@objc protocol ObjCClassBound {
@@ -214,7 +214,7 @@ func objc_class_bounded_protocol_conversion_4
214
214
}
215
215
216
216
// CHECK-LABEL: define hidden swiftcc { i64, %objc_object*, i64 } @_T022class_bounded_generics0A28_generic_field_struct_fields{{[_0-9a-zA-Z]*}}F(i64, %objc_object*, i64, %swift.type* %T, i8** %T.ClassBound)
217
- func class_generic_field_struct_fields< T : ClassBound >
217
+ func class_generic_field_struct_fields< T>
218
218
( _ x: ClassGenericFieldStruct < T > ) -> ( Int , T , Int ) {
219
219
return ( x. x, x. y, x. z)
220
220
}
@@ -226,7 +226,7 @@ func class_protocol_field_struct_fields
226
226
}
227
227
228
228
// CHECK-LABEL: define hidden swiftcc { i64, %objc_object*, i64 } @_T022class_bounded_generics0a15_generic_field_A7_fields{{[_0-9a-zA-Z]*}}F(%T22class_bounded_generics017ClassGenericFieldD0C*)
229
- func class_generic_field_class_fields< T : ClassBound >
229
+ func class_generic_field_class_fields< T>
230
230
( _ x: ClassGenericFieldClass < T > ) -> ( Int , T , Int ) {
231
231
return ( x. x, x. y, x. z)
232
232
// CHECK: getelementptr inbounds %T22class_bounded_generics017ClassGenericFieldD0C, %T22class_bounded_generics017ClassGenericFieldD0C* %0, i32 0, i32 1
@@ -273,3 +273,36 @@ class M<T, S: A<T>> {
273
273
s = S . init ( )
274
274
}
275
275
}
276
+
277
+ // CHECK-LABEL: define hidden swiftcc void @_T022class_bounded_generics14takes_metatypeyxmlF(%swift.type*, %swift.type* %T)
278
+ func takes_metatype< T> ( _: T . Type ) { }
279
+
280
+ // CHECK-LABEL: define hidden swiftcc void @_T022class_bounded_generics023archetype_with_generic_A11_constraintyx1t_tAA1ACyq_GRbzr0_lF(%T22class_bounded_generics1AC.2*, %swift.type* %T)
281
+ // CHECK: [[ISA_ADDR:%.*]] = bitcast %T22class_bounded_generics1AC.2* %0 to %swift.type**
282
+ // CHECK-NEXT: [[ISA:%.*]] = load %swift.type*, %swift.type** [[ISA_ADDR]]
283
+ // CHECK-NEXT: call swiftcc void @_T022class_bounded_generics14takes_metatypeyxmlF(%swift.type* %T, %swift.type* %T)
284
+ // CHECK-NEXT: [[ISA_PTR:%.*]] = bitcast %swift.type* [[ISA]] to %swift.type**
285
+ // CHECK-NEXT: [[U_ADDR:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[ISA_PTR]], i64 10
286
+ // CHECK-NEXT: [[U:%.*]] = load %swift.type*, %swift.type** [[U_ADDR]]
287
+ // CHECK-NEXT: call swiftcc void @_T022class_bounded_generics14takes_metatypeyxmlF(%swift.type* %U, %swift.type* %U)
288
+ // CHECK: ret void
289
+
290
+ func archetype_with_generic_class_constraint< T, U> ( t: T ) where T : A < U > {
291
+ takes_metatype ( T . self)
292
+ takes_metatype ( U . self)
293
+ }
294
+
295
+ // CHECK-LABEL: define hidden swiftcc void @_T022class_bounded_generics029calls_archetype_with_generic_A11_constraintyAA1ACyxG1a_tlF(%T22class_bounded_generics1AC*) #0 {
296
+ // CHECK: [[ISA_ADDR:%.*]] = getelementptr inbounds %T22class_bounded_generics1AC, %T22class_bounded_generics1AC* %0, i32 0, i32 0, i32 0
297
+ // CHECK-NEXT: [[ISA:%.*]] = load %swift.type*, %swift.type** [[ISA_ADDR]]
298
+ // CHECK: [[SELF:%.*]] = bitcast %T22class_bounded_generics1AC* %0 to %T22class_bounded_generics1AC.2*
299
+ // CHECK-NEXT: [[ISA_PTR:%.*]] = bitcast %swift.type* [[ISA]] to %swift.type**
300
+ // CHECK-NEXT: [[T_ADDR:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[ISA_PTR]], i64 10
301
+ // CHECK-NEXT: [[T:%.*]] = load %swift.type*, %swift.type** [[T_ADDR]]
302
+ // CHECK-NEXT: [[A_OF_T:%.*]] = call %swift.type* @_T022class_bounded_generics1ACMa(%swift.type* [[T]])
303
+ // CHECK-NEXT: call swiftcc void @_T022class_bounded_generics023archetype_with_generic_A11_constraintyx1t_tAA1ACyq_GRbzr0_lF(%T22class_bounded_generics1AC.2* [[SELF]], %swift.type* [[A_OF_T]])
304
+ // CHECK: ret void
305
+
306
+ func calls_archetype_with_generic_class_constraint< T> ( a: A < T > ) {
307
+ archetype_with_generic_class_constraint ( t: a)
308
+ }
0 commit comments