forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneric_classes.sil
412 lines (366 loc) · 20.1 KB
/
generic_classes.sil
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
// RUN: rm -rf %t && mkdir %t
// RUN: %build-irgen-test-overlays
// RUN: %target-swift-frontend -sdk %S/Inputs -I %t %s -emit-ir | FileCheck %s
// REQUIRES: CPU=x86_64
// XFAIL: linux
import Builtin
import Swift
import gizmo
// CHECK: [[ROOTGENERIC:%C15generic_classes11RootGeneric]] = type <{ %swift.refcounted, %Vs5UInt8 }>
// -- offset of RootGeneric<T>.x
// CHECK: [[ROOTGENERIC_NAME:@.*]] = private unnamed_addr constant [32 x i8] c"C15generic_classes11RootGeneric\00"
// CHECK: [[ROOTGENERIC_FIELDS:@.*]] = private unnamed_addr constant [7 x i8] c"x\00y\00z\00\00"
// CHECK: @_TMnC15generic_classes11RootGeneric = constant { {{.*}} i32 } {
// -- 0 = class
// CHECK: i64 0,
// -- name
// CHECK: i8* getelementptr inbounds ([32 x i8], [32 x i8]* [[ROOTGENERIC_NAME]], i64 0, i64 0),
// -- num fields
// CHECK: i32 3,
// -- field offset vector offset
// CHECK: i32 15,
// -- field names
// CHECK: i8* getelementptr inbounds ([7 x i8], [7 x i8]* [[ROOTGENERIC_FIELDS]], i64 0, i64 0),
// -- generic metadata pattern
// CHECK: @_TMPC15generic_classes11RootGeneric
// -- generic parameter vector offset
// CHECK: i32 10,
// -- generic parameter count, primary count, witness table counts
// CHECK: i32 1, i32 1, i32 0
// CHECK: }
// CHECK: @_TMPC15generic_classes11RootGeneric = global { {{.*}}* } } {
// -- template fill function
// CHECK: %swift.type* (%swift.type_pattern*, i8**)* @create_generic_metadata_RootGeneric
// -- nominal type descriptor
// CHECK: @_TMnC15generic_classes11RootGeneric,
// -- vtable
// CHECK: @_TFC15generic_classes11RootGeneric3fooU__fGS0_Q__FT_T_,
// CHECK: @_TFC15generic_classes11RootGeneric3barU__fGS0_Q__FT_T_,
// CHECK: @_TFC15generic_classes11RootGeneric3basU__fGS0_Q__FT_T_,
// -- field offset placeholders
// CHECK: i64 16, i64 0, i64 0
// CHECK: }
// -- Check that offset vars are emitted for fixed-layout generics
// <rdar://problem/15081049>
// CHECK: @_TWvdvC15generic_classes22RootGenericFixedLayout1xVs5UInt8 = global i64 16, align 8
// CHECK: @_TWvdvC15generic_classes22RootGenericFixedLayout1yGSax_ = global i64 24, align 8
// CHECK: @_TWvdvC15generic_classes22RootGenericFixedLayout1zVs5UInt8 = global i64 32, align 8
// -- fixed-layout nongeneric descriptor
// CHECK: [[ROOTNONGENERIC_NAME:@.*]] = private unnamed_addr constant [35 x i8] c"C15generic_classes14RootNonGeneric\00"
// CHECK: @_TMnC15generic_classes14RootNonGeneric = constant { {{.*}} i32 } {
// -- 0 = class
// CHECK: i64 0,
// -- name
// CHECK: i8* getelementptr inbounds ([35 x i8], [35 x i8]* [[ROOTNONGENERIC_NAME]], i64 0, i64 0),
// -- num fields
// CHECK: i32 3,
// -- -- field offset vector offset
// CHECK: i32 11,
// -- field names
// CHECK: i8* getelementptr inbounds ([7 x i8], [7 x i8]* [[ROOTGENERIC_FIELDS]], i64 0, i64 0),
// -- no generic metadata pattern
// CHECK: %swift.type_pattern* null,
// -- 0 = no generic parameter vector
// CHECK: i32 0,
// -- number of generic params, primary params
// CHECK: i32 0, i32 0
// CHECK: }
// CHECK: @_TMfC15generic_classes14RootNonGeneric = internal global { {{.*}} } {
// CHECK: void (%C15generic_classes14RootNonGeneric*)* @_TFC15generic_classes14RootNonGenericD,
// CHECK: i8** @_TWVBo,
// CHECK: i64 ptrtoint (%objc_class* @_TMmC15generic_classes14RootNonGeneric to i64),
// CHECK: %objc_class* @"OBJC_CLASS_$_SwiftObject",
// CHECK: %swift.opaque* @_objc_empty_cache,
// CHECK: %swift.opaque* null,
// CHECK: @_DATA__TtC15generic_classes14RootNonGeneric
// CHECK: i32 33,
// CHECK: i16 7,
// CHECK: i16 0,
// CHECK: {{.*}}* @_TMnC15generic_classes14RootNonGeneric,
// CHECK: }
// CHECK: @_TMPC15generic_classes22GenericInheritsGeneric = global { {{.*}}* } } {
// -- template fill function
// CHECK: %swift.type* (%swift.type_pattern*, i8**)* @create_generic_metadata_GenericInheritsGeneric
// -- RootGeneric vtable
// CHECK: @_TFC15generic_classes11RootGeneric3fooU__fGS0_Q__FT_T_,
// CHECK: @_TFC15generic_classes11RootGeneric3barU__fGS0_Q__FT_T_,
// CHECK: @_TFC15generic_classes11RootGeneric3basU__fGS0_Q__FT_T_,
// -- RootGeneric field offset placeholders
// CHECK: i64 16, i64 0, i64 0
// -- GenericInheritsGeneric vtable
// CHECK: @_TFC15generic_classes22GenericInheritsGeneric7zippityU___fGS0_Q_Q0__FT_T_,
// CHECK: @_TFC15generic_classes22GenericInheritsGeneric3dooU___fGS0_Q_Q0__FT_T_,
// CHECK: @_TFC15generic_classes22GenericInheritsGeneric3dahU___fGS0_Q_Q0__FT_T_,
// -- GenericInheritsGeneric field offset placeholder
// CHECK: i64 0
// CHECK: }
// CHECK: @_TMPC15generic_classes25GenericInheritsNonGeneric
class RootGeneric<T> {
var x : UInt8
init()
// Test that declaration order doesn't cause the field offset vector to end
// up interleaved with the vtable.
func foo()
var y : T
func bar()
var z : UInt8
func bas()
}
sil @_TFC15generic_classes11RootGenericD : $@convention(method) <T> (RootGeneric<T>) -> ()
sil @_TFC15generic_classes11RootGeneric3fooU__fGS0_Q__FT_T_ : $@convention(method) <T> (@guaranteed RootGeneric<T>) -> ()
sil @_TFC15generic_classes11RootGeneric3barU__fGS0_Q__FT_T_ : $@convention(method) <T> (@guaranteed RootGeneric<T>) -> ()
sil @_TFC15generic_classes11RootGeneric3basU__fGS0_Q__FT_T_ : $@convention(method) <T> (@guaranteed RootGeneric<T>) -> ()
sil_vtable RootGeneric {
#RootGeneric.foo!1: _TFC15generic_classes11RootGeneric3fooU__fGS0_Q__FT_T_
#RootGeneric.bar!1: _TFC15generic_classes11RootGeneric3barU__fGS0_Q__FT_T_
#RootGeneric.bas!1: _TFC15generic_classes11RootGeneric3basU__fGS0_Q__FT_T_
}
class RootGenericFixedLayout<T> {
var x : UInt8
var y : [T]
var z : UInt8
init()
}
sil_vtable RootGenericFixedLayout {}
sil @_TFC15generic_classes22RootGenericFixedLayoutD : $@convention(method) <T> (RootGenericFixedLayout<T>) -> ()
class RootNonGeneric {
var x : UInt8
var y : Int
var z : UInt8
init()
}
sil_vtable RootNonGeneric {}
sil @_TFC15generic_classes14RootNonGenericD : $@convention(method) (RootNonGeneric) -> ()
class GenericInheritsGeneric<A, B> : RootGeneric<A> {
var w : B
func zippity()
func doo()
func dah()
override init()
}
sil @_TFC15generic_classes22GenericInheritsGenericD : $@convention(method) <T,U> (GenericInheritsGeneric<T,U>) -> ()
sil @_TFC15generic_classes22GenericInheritsGeneric7zippityU___fGS0_Q_Q0__FT_T_ : $@convention(method) <A, B> (@guaranteed GenericInheritsGeneric<A, B>) -> ()
sil @_TFC15generic_classes22GenericInheritsGeneric3dooU___fGS0_Q_Q0__FT_T_ : $@convention(method) <A, B> (@guaranteed GenericInheritsGeneric<A, B>) -> ()
sil @_TFC15generic_classes22GenericInheritsGeneric3dahU___fGS0_Q_Q0__FT_T_ : $@convention(method) <A, B> (@guaranteed GenericInheritsGeneric<A, B>) -> ()
sil_vtable GenericInheritsGeneric {
#RootGeneric.foo!1: _TFC15generic_classes11RootGeneric3fooU__fGS0_Q__FT_T_
#RootGeneric.bar!1: _TFC15generic_classes11RootGeneric3barU__fGS0_Q__FT_T_
#RootGeneric.bas!1: _TFC15generic_classes11RootGeneric3basU__fGS0_Q__FT_T_
#GenericInheritsGeneric.zippity!1: _TFC15generic_classes22GenericInheritsGeneric7zippityU___fGS0_Q_Q0__FT_T_
#GenericInheritsGeneric.doo!1: _TFC15generic_classes22GenericInheritsGeneric3dooU___fGS0_Q_Q0__FT_T_
#GenericInheritsGeneric.dah!1: _TFC15generic_classes22GenericInheritsGeneric3dahU___fGS0_Q_Q0__FT_T_
}
class GenericInheritsNonGeneric<C> : RootNonGeneric {
var w : UInt8
override init()
}
sil_vtable GenericInheritsNonGeneric {}
sil @_TFC15generic_classes25GenericInheritsNonGenericD : $@convention(method) <T> (GenericInheritsNonGeneric<T>) -> ()
// rdar://18067671
class RecursiveGenericInheritsGeneric<A, B> : RootGeneric<A> {
var w : B
var r : RecursiveGenericInheritsGeneric<A, B>?
func zippity()
func doo()
func dah()
override init()
}
sil_vtable RecursiveGenericInheritsGeneric {}
sil @_TFC15generic_classes31RecursiveGenericInheritsGenericD : $@convention(method) <T,U> (RecursiveGenericInheritsGeneric<T,U>) -> ()
// CHECK: define [[ROOTGENERIC]]* @RootGeneric_fragile_dependent_alloc
// CHECK: [[METADATA:%.*]] = call %swift.type* @swift_getGenericMetadata
// CHECK: [[METADATA_ARRAY:%.*]] = bitcast %swift.type* [[METADATA]] to i8*
// CHECK: [[T0:%.*]] = getelementptr inbounds i8, i8* [[METADATA_ARRAY]], i32 48
// CHECK: [[T1:%.*]] = bitcast i8* [[T0]] to i32*
// CHECK: [[SIZE32:%.*]] = load i32, i32* [[T1]], align 8
// CHECK: [[SIZE:%.*]] = zext i32 [[SIZE32]] to i64
// CHECK: [[T0:%.*]] = getelementptr inbounds i8, i8* [[METADATA_ARRAY]], i32 52
// CHECK: [[T1:%.*]] = bitcast i8* [[T0]] to i32*
// CHECK: [[ALIGN32:%.*]] = load i32, i32* [[T1]], align 4
// CHECK: [[ALIGN:%.*]] = zext i32 [[ALIGN32]] to i64
// CHECK: call noalias %swift.refcounted* @swift_allocObject(%swift.type* [[METADATA]], i64 [[SIZE]], i64 [[ALIGN]])
sil @RootGeneric_fragile_dependent_alloc : $<G> () -> RootGeneric<G> {
entry:
%x = alloc_ref $RootGeneric<G>
return %x : $RootGeneric<G>
}
// RootGeneric.x has fixed layout
// CHECK: define i8 @RootGeneric_concrete_fragile_dependent_member_access_x
// CHECK: getelementptr inbounds [[ROOTGENERIC]], [[ROOTGENERIC]]* %0, i32 0, i32 1
sil @RootGeneric_concrete_fragile_dependent_member_access_x : $<F> RootGeneric<F> -> UInt8 {
entry(%c : $RootGeneric<F>):
%p = ref_element_addr %c : $RootGeneric<F>, #RootGeneric.x
%x = load %p : $*UInt8
return %x : $UInt8
}
// RootGeneric.y has dependent layout; load the offset from the metadata
// CHECK-LABEL: define void @RootGeneric_concrete_fragile_dependent_member_access_y
// CHECK: [[TYPE_METADATA_ARRAY:%.*]] = bitcast %swift.type* {{%.*}} to i8***
// CHECK: [[Y_OFFSET_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[TYPE_METADATA_ARRAY]], i64 16
// CHECK: [[Y_OFFSET_PTR:%.*]] = load i8**, i8*** [[Y_OFFSET_ADDR]], align 8
// CHECK: [[Y_OFFSET:%.*]] = ptrtoint i8** [[Y_OFFSET_PTR]] to i64
// CHECK: [[CLASS_BYTE_ARRAY:%.*]] = bitcast [[ROOTGENERIC]]* {{%.*}} to i8*
// CHECK: [[Y_ADDR:%.*]] = getelementptr inbounds i8, i8* [[CLASS_BYTE_ARRAY]], i64 [[Y_OFFSET]]
// CHECK: bitcast i8* [[Y_ADDR]] to %swift.opaque*
sil @RootGeneric_concrete_fragile_dependent_member_access_y : $<F> (@out F, RootGeneric<F>) -> () {
entry(%z : $*F, %c : $RootGeneric<F>):
%p = ref_element_addr %c : $RootGeneric<F>, #RootGeneric.y
copy_addr %p to [initialization] %z : $*F
%t = tuple ()
return %t : $()
}
// CHECK-LABEL: define void @RootGeneric_subst_concrete_fragile_dependent_member_access_y
// CHECK: [[TYPE_METADATA_ARRAY:%.*]] = bitcast %swift.type* {{%.*}} to i8***
// CHECK: [[Y_OFFSET_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[TYPE_METADATA_ARRAY]], i64 16
// CHECK: [[Y_OFFSET_PTR:%.*]] = load i8**, i8*** [[Y_OFFSET_ADDR]], align 8
// CHECK: [[Y_OFFSET:%.*]] = ptrtoint i8** [[Y_OFFSET_PTR]] to i64
// CHECK: [[CLASS_BYTE_ARRAY:%.*]] = bitcast [[ROOTGENERIC]]* {{%.*}} to i8*
// CHECK: [[Y_ADDR:%.*]] = getelementptr inbounds i8, i8* [[CLASS_BYTE_ARRAY]], i64 [[Y_OFFSET]]
// CHECK: bitcast i8* [[Y_ADDR]] to %Si*
sil @RootGeneric_subst_concrete_fragile_dependent_member_access_y : $(@out Int, RootGeneric<Int>) -> () {
entry(%z : $*Int, %c : $RootGeneric<Int>):
%p = ref_element_addr %c : $RootGeneric<Int>, #RootGeneric.y
copy_addr %p to [initialization] %z : $*Int
%t = tuple ()
return %t : $()
}
// RootGeneric.z has dependent layout; load the offset from the metadata
// CHECK-LABEL: define i8 @RootGeneric_concrete_fragile_dependent_member_access_z
// CHECK: [[TYPE_METADATA_ARRAY:%.*]] = bitcast %swift.type* {{%.*}} to i8***
// CHECK: [[Z_OFFSET_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[TYPE_METADATA_ARRAY]], i64 17
// CHECK: [[Z_OFFSET_PTR:%.*]] = load i8**, i8*** [[Z_OFFSET_ADDR]], align 8
// CHECK: [[Z_OFFSET:%.*]] = ptrtoint i8** [[Z_OFFSET_PTR]] to i64
// CHECK: [[CLASS_BYTE_ARRAY:%.*]] = bitcast [[ROOTGENERIC]]* {{%.*}} to i8*
// CHECK: [[Z_ADDR:%.*]] = getelementptr inbounds i8, i8* [[CLASS_BYTE_ARRAY]], i64 [[Z_OFFSET]]
// CHECK: bitcast i8* [[Z_ADDR]] to %Vs5UInt8*
sil @RootGeneric_concrete_fragile_dependent_member_access_z : $<F> RootGeneric<F> -> UInt8 {
entry(%c : $RootGeneric<F>):
%p = ref_element_addr %c : $RootGeneric<F>, #RootGeneric.z
%z = load %p : $*UInt8
return %z : $UInt8
}
// CHECK-LABEL: define i8 @RootGeneric_subst_concrete_fragile_dependent_member_access_z
// CHECK: [[TYPE_METADATA_ARRAY:%.*]] = bitcast %swift.type* {{%.*}} to i8***
// CHECK: [[Z_OFFSET_ADDR:%.*]] = getelementptr inbounds i8**, i8*** [[TYPE_METADATA_ARRAY]], i64 17
// CHECK: [[Z_OFFSET_PTR:%.*]] = load i8**, i8*** [[Z_OFFSET_ADDR]], align 8
// CHECK: [[Z_OFFSET:%.*]] = ptrtoint i8** [[Z_OFFSET_PTR]] to i64
// CHECK: [[CLASS_BYTE_ARRAY:%.*]] = bitcast [[ROOTGENERIC]]* {{%.*}} to i8*
// CHECK: [[Z_ADDR:%.*]] = getelementptr inbounds i8, i8* [[CLASS_BYTE_ARRAY]], i64 [[Z_OFFSET]]
// CHECK: bitcast i8* [[Z_ADDR]] to %Vs5UInt8*
sil @RootGeneric_subst_concrete_fragile_dependent_member_access_z : $RootGeneric<Int> -> UInt8 {
entry(%c : $RootGeneric<Int>):
%p = ref_element_addr %c : $RootGeneric<Int>, #RootGeneric.z
%z = load %p : $*UInt8
return %z : $UInt8
}
/* TODO: Instantiate types for fragile generic instances so we can do
* fixed-layout access
sil @RootGeneric_concrete_fragile_fixed_member_access : $RootGeneric<Int32> -> (UInt8, Int32, UInt8) {
entry(%c : $RootGeneric<Int32>):
%p = ref_element_addr %c : $RootGeneric<Int32>, #RootGeneric.x
%x = load %p : $*UInt8
%q = ref_element_addr %c : $RootGeneric<Int32>, #RootGeneric.y
%y = load %q : $*Int32
%r = ref_element_addr %c : $RootGeneric<Int32>, #RootGeneric.z
%z = load %r : $*UInt8
%t = tuple (%x : $UInt8, %y : $Int32, %z : $UInt8)
return %t : $(UInt8, Int32, UInt8)
}
*/
// CHECK: define private %swift.type* @create_generic_metadata_RootGeneric(%swift.type_pattern*, i8**) {{.*}} {
// -- initialize the dependent field offsets
// CHECK: call void @swift_initClassMetadata_UniversalStrategy(%swift.type* {{%.*}}, %swift.type* null, i64 3, i64* {{%.*}}, i64* {{%.*}})
// CHECK: }
// CHECK: define private %swift.type* @create_generic_metadata_GenericInheritsGeneric(%swift.type_pattern*, i8**) {{.*}} {
// Bind the generic parameters.
// CHECK: [[T0:%.*]] = load i8*, i8** %1
// CHECK: %A = bitcast i8* [[T0]] to %swift.type*
// CHECK: [[T0:%.*]] = getelementptr inbounds i8*, i8** %1, i32 1
// CHECK: [[T1:%.*]] = load i8*, i8** [[T0]]
// CHECK: %B = bitcast i8* [[T1]] to %swift.type*
// Construct the superclass.
// CHECK: [[T0:%.*]] = bitcast %swift.type* %A to i8*
// CHECK: [[SUPER:%.*]] = call %swift.type* @swift_getGenericMetadata1(%swift.type_pattern* {{.*}} @_TMPC15generic_classes11RootGeneric {{.*}}, i8* [[T0]])
// CHECK: [[T0:%.*]] = bitcast %swift.type* [[SUPER]] to %objc_class*
// CHECK: [[METADATA:%.*]] = call %swift.type* @swift_allocateGenericClassMetadata(%swift.type_pattern* %0, i8** %1, %objc_class* [[T0]])
// CHECK: [[METADATA_ARRAY:%.*]] = bitcast %swift.type* [[METADATA]] to i8**
// Put the generic arguments in their correct positions.
// CHECK: [[T0:%.*]] = bitcast %swift.type* %A to i8*
// CHECK: [[A_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY:%.*]], i32 18
// CHECK: store i8* [[T0]], i8** [[A_ADDR]], align 8
// CHECK: [[T0:%.*]] = bitcast %swift.type* %B to i8*
// CHECK: [[B_ADDR:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY:%.*]], i32 19
// CHECK: store i8* [[T0]], i8** [[B_ADDR]], align 8
// Set up the isa.
// CHECK: [[METADATA_ARRAY:%.*]] = bitcast %swift.type* [[METADATA]] to i8**
// CHECK: [[T0:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 0
// CHECK: [[T1:%.*]] = bitcast i8** [[T0]] to %objc_class**
// CHECK: [[T0:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 25
// CHECK: [[METACLASS:%.*]] = bitcast i8** [[T0]] to %objc_class*
// CHECK: store %objc_class* [[METACLASS]], %objc_class** [[T1]], align 8
// Set up the instance rodata pointer.
// CHECK: [[T0:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 4
// CHECK: [[T1:%.*]] = bitcast i8** [[T0]] to i64*
// CHECK: [[RODATA:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 30
// CHECK: [[T2:%.*]] = ptrtoint i8** [[RODATA]] to i64
// CHECK: [[T3:%.*]] = or i64 [[T2]], 1
// CHECK: store i64 [[T3]], i64* [[T1]], align 8
// Set up the class rodata pointer.
// CHECK: [[T0:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 29
// CHECK: [[T1:%.*]] = bitcast i8** [[T0]] to i64*
// CHECK: [[META_RODATA:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 39
// CHECK: [[T2:%.*]] = ptrtoint i8** [[META_RODATA]] to i64
// CHECK: store i64 [[T2]], i64* [[T1]], align 8
// Set up the rodatas.
// CHECK: [[T0:%.*]] = call i8* @swift_getGenericClassObjCName(
// CHECK: [[T1:%.*]] = getelementptr inbounds i8*, i8** [[RODATA]], i32 3
// CHECK: store i8* [[T0]], i8** [[T1]], align 8
// CHECK: [[T1:%.*]] = getelementptr inbounds i8*, i8** [[META_RODATA]], i32 3
// CHECK: store i8* [[T0]], i8** [[T1]], align 8
// Load out the superclass.
// CHECK: [[T0:%.*]] = bitcast %swift.type* [[METADATA]] to %swift.type**
// CHECK: [[T1:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[T0]], i32 1
// CHECK: [[SUPER:%.*]] = load %swift.type*, %swift.type** [[T1]], align 8
// Set up the metaclass's superclass from the superclass's metaclass.
// CHECK: [[T0:%.*]] = bitcast %swift.type* [[SUPER]] to i64*
// CHECK: [[T1:%.*]] = load i64, i64* [[T0]], align 8
// CHECK: [[T2:%.*]] = load i64, i64* @swift_isaMask, align 8
// CHECK: [[T3:%.*]] = and i64 [[T1]], [[T2]]
// CHECK: [[SUPER_METACLASS:%.*]] = inttoptr i64 [[T3]] to %swift.type*
// CHECK: [[T0:%.*]] = bitcast %objc_class* [[METACLASS]] to %swift.type**
// CHECK: [[META_SUPERCLASS_ADDR:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[T0]], i32 1
// CHECK: store %swift.type* [[SUPER_METACLASS]], %swift.type** [[META_SUPERCLASS_ADDR]]
// Copy various stuff from the superclass:
// CHECK: [[SUPER_ARRAY:%.*]] = bitcast %swift.type* [[SUPER]] to i64*
// CHECK: [[METADATA_ARRAY:%.*]] = bitcast %swift.type* [[METADATA]] to i64*
// - the superclass's generic args
// CHECK: [[SUPER_T_ADDR:%.*]] = getelementptr inbounds i64, i64* [[SUPER_ARRAY]], i32 10
// CHECK: [[SELF_T_ADDR:%.*]] = getelementptr inbounds i64, i64* [[METADATA_ARRAY]], i32 10
// CHECK: [[T:%.*]] = load i64, i64* [[SUPER_T_ADDR]], align 8
// CHECK: store i64 [[T]], i64* [[SELF_T_ADDR]], align 8
// - the super field offsets
// CHECK: [[SUPER_BASE_VEC:%.*]] = getelementptr inbounds i64, i64* [[SUPER_ARRAY]], i32 15
// CHECK: [[SELF_BASE_VEC:%.*]] = getelementptr inbounds i64, i64* [[METADATA_ARRAY]], i32 15
// CHECK: [[SELF_BASE_VEC_I8:%.*]] = bitcast i64* [[SELF_BASE_VEC]] to i8*
// CHECK: [[SUPER_BASE_VEC_I8:%.*]] = bitcast i64* [[SUPER_BASE_VEC]] to i8*
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[SELF_BASE_VEC_I8]], i8* [[SUPER_BASE_VEC_I8]], i64 24, i32 8, i1 false)
// Initialize our own dependent field offsets.
// CHECK: [[METADATA_ARRAY:%.*]] = bitcast %swift.type* [[METADATA]] to i64*
// CHECK: [[OFFSETS:%.*]] = getelementptr inbounds i64, i64* [[METADATA_ARRAY]], i32 23
// CHECK: [[T0:%.*]] = bitcast %swift.type* %B to i8***
// CHECK: [[T1:%.*]] = getelementptr inbounds i8**, i8*** [[T0]], i64 -1
// CHECK: [[VWT:%.*]] = load i8**, i8*** [[T1]], align 8
// CHECK: [[T0:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], i32 17
// CHECK: [[T1:%.*]] = load i8*, i8** [[T0]], align 8
// CHECK: [[SIZE:%.*]] = ptrtoint i8* [[T1]] to i64
// CHECK: [[T0:%.*]] = getelementptr inbounds i8*, i8** [[VWT]], i32 18
// CHECK: [[T1:%.*]] = load i8*, i8** [[T0]], align 8
// CHECK: [[T2:%.*]] = ptrtoint i8* [[T1]] to i64
// CHECK: [[ALIGN:%.*]] = and i64 [[T2]], 65535
// CHECK: [[SIZE_ADDR:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[TYPES:%.*]], i32 0, i32 0
// CHECK: store i64 [[SIZE]], i64* [[SIZE_ADDR]], align 8
// CHECK: [[ALIGN_ADDR:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[TYPES]], i32 0, i32 1
// CHECK: store i64 [[ALIGN]], i64* [[ALIGN_ADDR]], align 8
// CHECK: call void @swift_initClassMetadata_UniversalStrategy(%swift.type* [[METADATA]], %swift.type* [[SUPER]], i64 1, i64* [[SIZE_ADDR]], i64* [[OFFSETS]])
// CHECK: ret %swift.type* [[METADATA]]
// CHECK: }