@@ -37,6 +37,10 @@ struct A {
37
37
var i : Builtin.Int32
38
38
}
39
39
40
+ struct A2 {
41
+ var i : Builtin.Int32
42
+ }
43
+
40
44
struct AA {
41
45
var a : A
42
46
var i : Builtin.Int32
@@ -1348,3 +1352,85 @@ bb0:
1348
1352
return %5 : $Int32
1349
1353
}
1350
1354
1355
+ // CHECK: sil @tbaa_class_alias_nonclass
1356
+ // CHECK: strong_retain [[RET:%[0-9]+]]
1357
+ // CHECK: strong_retain [[RET]]
1358
+ // CHECK: return
1359
+ sil @tbaa_class_alias_nonclass : $@convention(thin) (@owned B, @inout Agg1) -> () {
1360
+ bb0(%0 : $B, %1 : $*Agg1):
1361
+ %2 = alloc_box $<τ_0_0> { var τ_0_0 } <B>
1362
+ %2a = project_box %2 : $<τ_0_0> { var τ_0_0 } <B>, 0
1363
+ %3 = load %1 : $*Agg1
1364
+ store %3 to %1 : $*Agg1
1365
+ %5 = load %2a : $*B
1366
+ store %3 to %1 : $*Agg1
1367
+ %7 = load %2a : $*B
1368
+ strong_retain %5 : $B //%7 and %5 should really be one load.
1369
+ strong_retain %7 : $B
1370
+ %10 = tuple()
1371
+ return %10 : $()
1372
+ }
1373
+
1374
+ // TODO: When RLE uses TBAA it should remove the second load.
1375
+ //
1376
+ // CHECK: sil @tbaa_struct
1377
+ // CHECK: load
1378
+ // CHECK: store
1379
+ // CHECK: load
1380
+ // CHECK: return
1381
+ sil @tbaa_struct : $@convention(thin) (Builtin.RawPointer, A2) -> (A, A) {
1382
+ bb0(%0 : $Builtin.RawPointer, %1 : $A2):
1383
+ %2 = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*A
1384
+ %3 = load %2 : $*A
1385
+ %5 = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*A2
1386
+ store %1 to %5 : $*A2
1387
+ %20 = load %2 : $*A
1388
+ %30 = tuple(%3 : $A, %20 : $A)
1389
+ return %30 : $(A, A)
1390
+ }
1391
+
1392
+ // TODO: Even with TBAA, RLE should not remove the second load.
1393
+ //
1394
+ // CHECK: sil @tbaa_bind_memory
1395
+ // CHECK: load
1396
+ // CHECK: bind_memory
1397
+ // CHECK: store
1398
+ // CHECK: bind_memory
1399
+ // CHECK: load
1400
+ // CHECK: return
1401
+ sil @tbaa_bind_memory : $@convention(thin) (Builtin.RawPointer, A2) -> (A, A) {
1402
+ bb0(%0 : $Builtin.RawPointer, %1 : $A2):
1403
+ %2 = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*A
1404
+ %3 = load %2 : $*A
1405
+ %4 = integer_literal $Builtin.Word, 1
1406
+ %5 = bind_memory %0 : $Builtin.RawPointer, %4 : $Builtin.Word to $A2
1407
+ %6 = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*A2
1408
+ store %1 to %6 : $*A2
1409
+ %8 = bind_memory %0 : $Builtin.RawPointer, %4 : $Builtin.Word to $A
1410
+ %20 = load %2 : $*A
1411
+ %30 = tuple(%3 : $A, %20 : $A)
1412
+ return %30 : $(A, A)
1413
+ }
1414
+
1415
+ // TODO: Even with TBAA, RLE should not remove the second load.
1416
+ //
1417
+ // CHECK: sil @tbaa_rebind_memory
1418
+ // CHECK: load
1419
+ // CHECK: bind_memory
1420
+ // CHECK: store
1421
+ // CHECK: bind_memory
1422
+ // CHECK: load
1423
+ // CHECK: return
1424
+ sil @tbaa_rebind_memory : $@convention(thin) (Builtin.RawPointer, A2) -> (A, A) {
1425
+ bb0(%0 : $Builtin.RawPointer, %1 : $A2):
1426
+ %2 = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*A
1427
+ %3 = load %2 : $*A
1428
+ %4 = integer_literal $Builtin.Word, 1
1429
+ %5 = bind_memory %0 : $Builtin.RawPointer, %4 : $Builtin.Word to $A2
1430
+ %6 = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*A2
1431
+ store %1 to %6 : $*A2
1432
+ %8 = rebind_memory %0 : $Builtin.RawPointer to %5 : $Builtin.Word
1433
+ %20 = load %2 : $*A
1434
+ %30 = tuple(%3 : $A, %20 : $A)
1435
+ return %30 : $(A, A)
1436
+ }
0 commit comments