1
- // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir
1
+ // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
2
2
3
3
struct A < T1, T2>
4
4
{
@@ -25,3 +25,35 @@ struct Foo<A1, A2>
25
25
26
26
struct Bar < A1, A2> {
27
27
}
28
+
29
+ public protocol Proto { }
30
+
31
+ public struct EmptyStruct { }
32
+
33
+ public struct GenericStruct < T : Proto > {
34
+ var empty : EmptyStruct = EmptyStruct ( )
35
+ var dummy : Int = 0
36
+ var opt : Optional < T > = nil
37
+
38
+ public init ( ) { }
39
+ }
40
+
41
+ // CHECK-32-LABEL: define{{.*}} swiftcc void @"$S15generic_structs13GenericStructVACyxGycfC"
42
+ // CHECK-32: [[TYPE:%.*]] = call %swift.type* @"$S15generic_structs13GenericStructVMa"(%swift.type* %T, i8** %T.Proto)
43
+ // CHECK-32: [[PTR:%.*]] = bitcast %swift.type* [[TYPE]] to i32*
44
+ // CHECK-32: [[FIELDOFFSETS:%.*]] = getelementptr inbounds i32, i32* [[PTR]], i32 2
45
+ // CHECK-32: [[FIELDOFFSET:%.*]] = getelementptr inbounds i32, i32* [[FIELDOFFSETS]], i32 2
46
+ // CHECK-32: [[OFFSET:%.*]] = load i32, i32* [[FIELDOFFSET]]
47
+ // CHECK-32: [[ADDROFOPT:%.*]] = getelementptr inbounds i8, i8* {{.*}}, i32 [[OFFSET]]
48
+ // CHECK-32: [[OPTPTR:%.*]] = bitcast i8* [[ADDROFOPT]] to %TSq*
49
+ // CHECK-32: call %TSq* @"$S15generic_structsytWb3_"(%TSq* {{.*}}, %TSq* [[OPTPTR]]
50
+
51
+ // CHECK-64-LABEL: define{{.*}} swiftcc void @"$S15generic_structs13GenericStructVACyxGycfC"
52
+ // CHECK-64: [[TYPE:%.*]] = call %swift.type* @"$S15generic_structs13GenericStructVMa"(%swift.type* %T, i8** %T.Proto)
53
+ // CHECK-64: [[PTR:%.*]] = bitcast %swift.type* [[TYPE]] to i64*
54
+ // CHECK-64: [[FIELDOFFSETS:%.*]] = getelementptr inbounds i64, i64* [[PTR]], i64 2
55
+ // CHECK-64: [[FIELDOFFSET:%.*]] = getelementptr inbounds i64, i64* [[FIELDOFFSETS]], i32 2
56
+ // CHECK-64: [[OFFSET:%.*]] = load i64, i64* [[FIELDOFFSET]]
57
+ // CHECK-64: [[ADDROFOPT:%.*]] = getelementptr inbounds i8, i8* {{.*}}, i64 [[OFFSET]]
58
+ // CHECK-64: [[OPTPTR:%.*]] = bitcast i8* [[ADDROFOPT]] to %TSq*
59
+ // CHECK-64: call %TSq* @"$S15generic_structsytWb3_"(%TSq* {{.*}}, %TSq* [[OPTPTR]]
0 commit comments