@@ -48,28 +48,17 @@ bb0(%0 : $@thin X.Type):
48
48
// }
49
49
// Preserve begin/end scope for nested conflicts,
50
50
// after inlining (read|modify)AndPerform.
51
+ // need to split it into 3 SIL functions else merging would kick in and we would be testing something else
51
52
//
52
- // CHECK-LABEL: sil hidden @testNestedAccess : $@convention(thin) () -> () {
53
+ // CHECK-LABEL: sil hidden @testNestedAccess1 : $@convention(thin) () -> () {
53
54
// CHECK: [[F1:%.*]] = function_ref @testNestedAccessClosure1 : $@convention(thin) () -> ()
54
55
// CHECK: [[C1:%.*]] = convert_function [[F1]] : $@convention(thin) () -> () to $@convention(thin) @noescape () -> ()
55
56
// CHECK: [[TF1:%.*]] = thin_to_thick_function [[C1]] : $@convention(thin) @noescape () -> () to $@noescape @callee_guaranteed ()
56
57
// CHECK: [[A1:%.*]] = begin_access [read] [dynamic] %0 : $*X
57
58
// CHECK: apply [[TF1]]() : $@noescape @callee_guaranteed () -> ()
58
59
// CHECK: end_access [[A1]] : $*X
59
- // CHECK: [[F2:%.*]] = function_ref @testNestedAccessClosure2 : $@convention(thin) () -> ()
60
- // CHECK: [[C2:%.*]] = convert_function [[F2]] : $@convention(thin) () -> () to $@convention(thin) @noescape () -> ()
61
- // CHECK: [[TF2:%.*]] = thin_to_thick_function [[C2]] : $@convention(thin) @noescape () -> () to $@noescape @callee_guaranteed () -> ()
62
- // CHECK: [[A2:%.*]] = begin_access [modify] [dynamic] %0 : $*X
63
- // CHECK: apply [[TF2]]() : $@noescape @callee_guaranteed () -> ()
64
- // CHECK: end_access [[A2]] : $*X
65
- // CHECK: [[F3:%.*]] = function_ref @testNestedAccessClosure3 : $@convention(thin) () -> ()
66
- // CHECK: [[C3:%.*]] = convert_function [[F3]] : $@convention(thin) () -> () to $@convention(thin) @noescape () -> ()
67
- // CHECK: [[TF3:%.*]] = thin_to_thick_function [[C3]] : $@convention(thin) @noescape () -> () to $@noescape @callee_guaranteed () -> ()
68
- // CHECK: [[A3:%.*]] = begin_access [modify] [dynamic] %0 : $*X
69
- // CHECK: apply [[TF3]]() : $@noescape @callee_guaranteed () -> ()
70
- // CHECK: end_access [[A3]] : $*X
71
- // CHECK-LABEL: } // end sil function 'testNestedAccess'
72
- sil hidden @testNestedAccess : $@convention(thin) () -> () {
60
+ // CHECK-LABEL: } // end sil function 'testNestedAccess1'
61
+ sil hidden @testNestedAccess1 : $@convention(thin) () -> () {
73
62
bb0:
74
63
%2 = global_addr @globalX: $*X
75
64
%3 = function_ref @testNestedAccessClosure1 : $@convention(thin) () -> ()
78
67
%6 = begin_access [read] [dynamic] %2 : $*X
79
68
%9 = apply %5() : $@noescape @callee_guaranteed () -> ()
80
69
end_access %6 : $*X
81
-
70
+ %36 = tuple ()
71
+ return %36 : $()
72
+ }
73
+ // CHECK-LABEL: sil hidden @testNestedAccess2 : $@convention(thin) () -> () {
74
+ // CHECK: [[F2:%.*]] = function_ref @testNestedAccessClosure2 : $@convention(thin) () -> ()
75
+ // CHECK: [[C2:%.*]] = convert_function [[F2]] : $@convention(thin) () -> () to $@convention(thin) @noescape () -> ()
76
+ // CHECK: [[TF2:%.*]] = thin_to_thick_function [[C2]] : $@convention(thin) @noescape () -> () to $@noescape @callee_guaranteed () -> ()
77
+ // CHECK: [[A2:%.*]] = begin_access [modify] [dynamic] %0 : $*X
78
+ // CHECK: apply [[TF2]]() : $@noescape @callee_guaranteed () -> ()
79
+ // CHECK: end_access [[A2]] : $*X
80
+ // CHECK-LABEL: } // end sil function 'testNestedAccess2'
81
+ sil hidden @testNestedAccess2 : $@convention(thin) () -> () {
82
+ bb0:
83
+ %2 = global_addr @globalX: $*X
82
84
%15 = function_ref @testNestedAccessClosure2 : $@convention(thin) () -> ()
83
85
%16 = convert_function %15 : $@convention(thin) () -> () to $@convention(thin) @noescape () -> ()
84
86
%17 = thin_to_thick_function %16 : $@convention(thin) @noescape () -> () to $@noescape @callee_guaranteed () -> ()
85
87
%18 = begin_access [modify] [dynamic] %2 : $*X
86
88
%21 = apply %17() : $@noescape @callee_guaranteed () -> ()
87
89
end_access %18 : $*X
88
-
90
+ %36 = tuple ()
91
+ return %36 : $()
92
+ }
93
+ // CHECK-LABEL: sil hidden @testNestedAccess3 : $@convention(thin) () -> () {
94
+ // CHECK: [[F3:%.*]] = function_ref @testNestedAccessClosure3 : $@convention(thin) () -> ()
95
+ // CHECK: [[C3:%.*]] = convert_function [[F3]] : $@convention(thin) () -> () to $@convention(thin) @noescape () -> ()
96
+ // CHECK: [[TF3:%.*]] = thin_to_thick_function [[C3]] : $@convention(thin) @noescape () -> () to $@noescape @callee_guaranteed () -> ()
97
+ // CHECK: [[A3:%.*]] = begin_access [modify] [dynamic] %0 : $*X
98
+ // CHECK: apply [[TF3]]() : $@noescape @callee_guaranteed () -> ()
99
+ // CHECK: end_access [[A3]] : $*X
100
+ // CHECK-LABEL: } // end sil function 'testNestedAccess3'
101
+ sil hidden @testNestedAccess3 : $@convention(thin) () -> () {
102
+ bb0:
103
+ %2 = global_addr @globalX: $*X
89
104
%27 = function_ref @testNestedAccessClosure3 : $@convention(thin) () -> ()
90
105
%28 = convert_function %27 : $@convention(thin) () -> () to $@convention(thin) @noescape () -> ()
91
106
%29 = thin_to_thick_function %28 : $@convention(thin) @noescape () -> () to $@noescape @callee_guaranteed () -> ()
@@ -1306,6 +1321,8 @@ class RefElemClass {
1306
1321
init()
1307
1322
}
1308
1323
1324
+ // Checks that we don't crash when unable to create projection paths
1325
+ // we can't merge anything here because of that
1309
1326
// CHECK-LABEL: sil @ref_elem_c : $@convention(thin) (RefElemClass) -> () {
1310
1327
// CHECK: [[GLOBAL:%.*]] = global_addr @globalX : $*X
1311
1328
// CHECK-NEXT: [[BEGIN:%.*]] = begin_access [read] [dynamic] [no_nested_conflict] [[GLOBAL]] : $*X
@@ -1314,8 +1331,10 @@ class RefElemClass {
1314
1331
// CHECK-NEXT: [[REFX:%.*]] = ref_element_addr %0 : $RefElemClass, #RefElemClass.x
1315
1332
// CHECK-NEXT: [[REFY:%.*]] = ref_element_addr %0 : $RefElemClass, #RefElemClass.y
1316
1333
// CHECK-NEXT: [[BEGINX:%.*]] = begin_access [modify] [dynamic] [[REFX]] : $*BitfieldOne
1334
+ // CHECK: end_access [[BEGINX]] : $*BitfieldOne
1317
1335
// CHECK: [[BEGINY:%.*]] = begin_access [modify] [dynamic] [no_nested_conflict] [[REFY]] : $*Int32
1318
- // CHECK-NEXT: end_access [[BEGINX]] : $*BitfieldOne
1336
+ // CHECK: [[BEGINX2:%.*]] = begin_access [modify] [dynamic] [no_nested_conflict] [[REFX]] : $*BitfieldOne
1337
+ // CHECK-NEXT: end_access [[BEGINX2]] : $*BitfieldOne
1319
1338
// CHECK-NEXT: end_access [[BEGINY]] : $*Int32
1320
1339
// CHECK-LABEL: } // end sil function 'ref_elem_c'
1321
1340
@@ -1417,3 +1436,55 @@ bb6:
1417
1436
%19 = tuple ()
1418
1437
return %19 : $()
1419
1438
}
1439
+
1440
+ // public func testMergeWithFirstConflict() {
1441
+ // Check that we can merge scopes even if the first one of them has conflicts within it
1442
+ //
1443
+ // CHECK-LABEL: sil @testMergeWithFirstConflict : $@convention(thin) () -> () {
1444
+ // CHECK: [[GLOBAL:%.*]] = global_addr @globalX : $*X
1445
+ // CHECK-NEXT: [[BEGIN:%.*]] = begin_access [read] [dynamic] [[GLOBAL]] : $*X
1446
+ // CHECK: apply
1447
+ // CHECK-NEXT: load
1448
+ // CHECK-NEXT: end_access [[BEGIN]] : $*X
1449
+ // CHECK-NOT: begin_access
1450
+ // CHECK-LABEL: } // end sil function 'testMergeWithFirstConflict'
1451
+ sil @testMergeWithFirstConflict : $@convention(thin) () -> () {
1452
+ bb0:
1453
+ %0 = global_addr @globalX: $*X
1454
+ %4 = begin_access [read] [dynamic] %0 : $*X
1455
+ %u0 = function_ref @globalAddressor : $@convention(thin) () -> Builtin.RawPointer
1456
+ %u1 = apply %u0() : $@convention(thin) () -> Builtin.RawPointer
1457
+ end_access %4 : $*X
1458
+ %1 = begin_access [read] [dynamic] %0 : $*X
1459
+ %2 = load %1 : $*X
1460
+ end_access %1 : $*X
1461
+ %10 = tuple ()
1462
+ return %10 : $()
1463
+ }
1464
+
1465
+ // public func testMergeWithSecondConflict() {
1466
+ // Check that we can merge scopes even if the 2nd one of them has conflicts within it
1467
+ //
1468
+ // CHECK-LABEL: sil @testMergeWithSecondConflict : $@convention(thin) () -> () {
1469
+ // CHECK: [[GLOBAL:%.*]] = global_addr @globalX : $*X
1470
+ // CHECK-NEXT: [[BEGIN:%.*]] = begin_access [read] [dynamic] [[GLOBAL]] : $*X
1471
+ // CHECK: load
1472
+ // CHECK: apply
1473
+ // CHECK-NEXT: end_access [[BEGIN]] : $*X
1474
+ // CHECK-NOT: begin_access
1475
+ // CHECK-LABEL: } // end sil function 'testMergeWithSecondConflict'
1476
+ sil @testMergeWithSecondConflict : $@convention(thin) () -> () {
1477
+ bb0:
1478
+ %0 = global_addr @globalX: $*X
1479
+ %1 = begin_access [read] [dynamic] %0 : $*X
1480
+ %2 = load %1 : $*X
1481
+ end_access %1 : $*X
1482
+ %4 = begin_access [read] [dynamic] %0 : $*X
1483
+ %u0 = function_ref @globalAddressor : $@convention(thin) () -> Builtin.RawPointer
1484
+ %u1 = apply %u0() : $@convention(thin) () -> Builtin.RawPointer
1485
+ end_access %4 : $*X
1486
+ %10 = tuple ()
1487
+ return %10 : $()
1488
+ }
1489
+
1490
+
0 commit comments