@@ -28,13 +28,15 @@ sil [ossa] @get_owned : $@convention(thin) () -> @owned C
28
28
// with an apply.
29
29
//
30
30
// CHECK-LABEL: sil [ossa] @fold_simplest : {{.*}} {
31
- // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
31
+ // CHECK: [[GET_OWNED:%[^,]+]] = function_ref @get_owned
32
+ // CHECK: [[INSTANCE:%[^,]+]] = apply [[GET_OWNED]]
32
33
// CHECK: [[CALEE_OWNED:%[^,]+]] = function_ref @callee_owned
33
34
// CHECK: [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]]
34
35
// CHECK: apply [[CALEE_OWNED]]([[MOVE]])
35
36
// CHECK-LABEL: } // end sil function 'fold_simplest'
36
- sil [ossa] @fold_simplest : $@convention(thin) (@owned C) -> () {
37
- entry(%instance : @owned $C):
37
+ sil [ossa] @fold_simplest : $@convention(thin) () -> () {
38
+ %get_owned = function_ref @get_owned : $@convention(thin) () -> (@owned C)
39
+ %instance = apply %get_owned() : $@convention(thin) () -> (@owned C)
38
40
%callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
39
41
%lifetime = begin_borrow [lexical] %instance : $C
40
42
%copy = copy_value %lifetime : $C
@@ -83,7 +85,8 @@ entry(%instance : @owned $C):
83
85
// borrowee intact on other paths.
84
86
//
85
87
// CHECK-LABEL: sil [ossa] @fold_left_only : {{.*}} {
86
- // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
88
+ // CHECK: [[GET_OWNED:%[^,]+]] = function_ref @get_owned
89
+ // CHECK: [[INSTANCE:%[^,]+]] = apply [[GET_OWNED]]
87
90
// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
88
91
// CHECK: cond_br undef, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
89
92
// CHECK: [[LEFT]]:
@@ -95,8 +98,10 @@ entry(%instance : @owned $C):
95
98
// CHECK: br [[EXIT]]
96
99
// CHECK: [[EXIT]]:
97
100
// CHECK-LABEL: } // end sil function 'fold_left_only'
98
- sil [ossa] @fold_left_only : $@convention(thin) (@owned C) -> () {
99
- entry(%instance : @owned $C):
101
+ sil [ossa] @fold_left_only : $@convention(thin) () -> () {
102
+ entry:
103
+ %get_owned = function_ref @get_owned : $@convention(thin) () -> (@owned C)
104
+ %instance = apply %get_owned() : $@convention(thin) () -> (@owned C)
100
105
%callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
101
106
cond_br undef, left, right
102
107
@@ -122,7 +127,8 @@ exit:
122
127
// independents owned lexical scopes.
123
128
//
124
129
// CHECK-LABEL: sil [ossa] @fold_two_independent_scopes : {{.*}} {
125
- // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
130
+ // CHECK: [[GET_OWNED:%[^,]+]] = function_ref @get_owned
131
+ // CHECK: [[INSTANCE:%[^,]+]] = apply [[GET_OWNED]]
126
132
// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
127
133
// CHECK: cond_br undef, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
128
134
// CHECK: [[LEFT]]:
@@ -135,8 +141,10 @@ exit:
135
141
// CHECK: br [[EXIT]]
136
142
// CHECK: [[EXIT]]:
137
143
// CHECK-LABEL: } // end sil function 'fold_two_independent_scopes'
138
- sil [ossa] @fold_two_independent_scopes : $@convention(thin) (@owned C) -> () {
139
- entry(%instance : @owned $C):
144
+ sil [ossa] @fold_two_independent_scopes : $@convention(thin) () -> () {
145
+ entry:
146
+ %get_owned = function_ref @get_owned : $@convention(thin) () -> (@owned C)
147
+ %instance = apply %get_owned() : $@convention(thin) () -> (@owned C)
140
148
%callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
141
149
cond_br undef, left, right
142
150
@@ -211,7 +219,8 @@ exit:
211
219
// within a single owned lexical scope.
212
220
//
213
221
// CHECK-LABEL: sil [ossa] @fold_two_parallel_applies___canonical_destroys : {{.*}} {
214
- // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
222
+ // CHECK: [[GET_OWNED:%[^,]+]] = function_ref @get_owned
223
+ // CHECK: [[INSTANCE:%[^,]+]] = apply [[GET_OWNED]]
215
224
// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
216
225
// CHECK: [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]] : $C
217
226
// CHECK: cond_br undef, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
@@ -223,8 +232,10 @@ exit:
223
232
// CHECK: br [[EXIT]]
224
233
// CHECK: [[EXIT]]:
225
234
// CHECK-LABEL: } // end sil function 'fold_two_parallel_applies___canonical_destroys'
226
- sil [ossa] @fold_two_parallel_applies___canonical_destroys : $@convention(thin) (@owned C) -> () {
227
- entry(%instance : @owned $C):
235
+ sil [ossa] @fold_two_parallel_applies___canonical_destroys : $@convention(thin) () -> () {
236
+ entry:
237
+ %get_owned = function_ref @get_owned : $@convention(thin) () -> (@owned C)
238
+ %instance = apply %get_owned() : $@convention(thin) () -> (@owned C)
228
239
%callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
229
240
%lifetime = begin_borrow [lexical] %instance : $C
230
241
cond_br undef, left, right
@@ -253,7 +264,8 @@ exit:
253
264
// borrowee that is not within the scope.
254
265
//
255
266
// CHECK-LABEL: sil [ossa] @fold_multiblock_borrow_single_apply_with_parallel_use : {{.*}} {
256
- // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
267
+ // CHECK: [[GET_OWNED:%[^,]+]] = function_ref @get_owned
268
+ // CHECK: [[INSTANCE:%[^,]+]] = apply [[GET_OWNED]]
257
269
// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
258
270
// CHECK: cond_br undef, [[LEFT1:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
259
271
// CHECK: [[LEFT1]]:
@@ -270,8 +282,10 @@ exit:
270
282
// CHECK: br [[EXIT]]
271
283
// CHECK: [[EXIT]]:
272
284
// CHECK-LABEL: } // end sil function 'fold_multiblock_borrow_single_apply_with_parallel_use'
273
- sil [ossa] @fold_multiblock_borrow_single_apply_with_parallel_use : $@convention(thin) (@owned C) -> () {
274
- entry(%instance : @owned $C):
285
+ sil [ossa] @fold_multiblock_borrow_single_apply_with_parallel_use : $@convention(thin) () -> () {
286
+ entry:
287
+ %get_owned = function_ref @get_owned : $@convention(thin) () -> (@owned C)
288
+ %instance = apply %get_owned() : $@convention(thin) () -> (@owned C)
275
289
%callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
276
290
cond_br undef, left1, right
277
291
@@ -306,7 +320,8 @@ exit:
306
320
// borrowee that is not within the scope.
307
321
//
308
322
// CHECK-LABEL: sil [ossa] @fold_multiblock_borrow_single_apply_and_parallel_singleblock_borrow : {{.*}} {
309
- // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
323
+ // CHECK: [[GET_OWNED:%[^,]+]] = function_ref @get_owned
324
+ // CHECK: [[INSTANCE:%[^,]+]] = apply [[GET_OWNED]]
310
325
// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
311
326
// CHECK: cond_br undef, [[LEFT1:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
312
327
// CHECK: [[LEFT1]]:
@@ -324,8 +339,10 @@ exit:
324
339
// CHECK: br [[EXIT]]
325
340
// CHECK: [[EXIT]]:
326
341
// CHECK-LABEL: } // end sil function 'fold_multiblock_borrow_single_apply_and_parallel_singleblock_borrow'
327
- sil [ossa] @fold_multiblock_borrow_single_apply_and_parallel_singleblock_borrow : $@convention(thin) (@owned C) -> () {
328
- entry(%instance : @owned $C):
342
+ sil [ossa] @fold_multiblock_borrow_single_apply_and_parallel_singleblock_borrow : $@convention(thin) () -> () {
343
+ entry:
344
+ %get_owned = function_ref @get_owned : $@convention(thin) () -> (@owned C)
345
+ %instance = apply %get_owned() : $@convention(thin) () -> (@owned C)
329
346
%callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
330
347
cond_br undef, left1, right
331
348
@@ -364,7 +381,8 @@ exit:
364
381
// guaranteed lifetime remains.
365
382
//
366
383
// CHECK-LABEL: sil [ossa] @fold_single_block_one_apply_double_use_all_owned : {{.*}} {
367
- // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
384
+ // CHECK: [[GET_OWNED:%[^,]+]] = function_ref @get_owned
385
+ // CHECK: [[INSTANCE:%[^,]+]] = apply [[GET_OWNED]]
368
386
// CHECK: [[LIFETIME:%[^,]+]] = move_value [lexical] [[INSTANCE]]
369
387
// CHECK: [[LIFETIME_GUARANTEED:%[^,]+]] = begin_borrow [lexical] [[LIFETIME]]
370
388
// CHECK: [[CALLEE_GUARANTEED:%[^,]+]] = function_ref @callee_guaranteed
@@ -374,8 +392,10 @@ exit:
374
392
// CHECK: [[CALLEE_OWNED_OWNED:%[^,]+]] = function_ref @callee_owned_owned
375
393
// CHECK: apply [[CALLEE_OWNED_OWNED]]([[LIFETIME]], [[COPY]])
376
394
// CHECK-LABEL: } // end sil function 'fold_single_block_one_apply_double_use_all_owned'
377
- sil [ossa] @fold_single_block_one_apply_double_use_all_owned : $@convention(thin) (@owned C) -> () {
378
- entry(%instance : @owned $C):
395
+ sil [ossa] @fold_single_block_one_apply_double_use_all_owned : $@convention(thin) () -> () {
396
+ entry:
397
+ %get_owned = function_ref @get_owned : $@convention(thin) () -> (@owned C)
398
+ %instance = apply %get_owned() : $@convention(thin) () -> (@owned C)
379
399
%lifetime = begin_borrow [lexical] %instance : $C
380
400
%callee_guaranteed = function_ref @callee_guaranteed : $@convention(thin) (@guaranteed C) -> ()
381
401
apply %callee_guaranteed(%lifetime) : $@convention(thin) (@guaranteed C) -> ()
@@ -393,14 +413,17 @@ entry(%instance : @owned $C):
393
413
// guaranteed lifetime remains.
394
414
//
395
415
// CHECK-LABEL: sil [ossa] @fold_single_block_one_apply_double_use_all_owned__no_remaining_uses : {{.*}} {
396
- // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
416
+ // CHECK: [[GET_OWNED:%[^,]+]] = function_ref @get_owned
417
+ // CHECK: [[INSTANCE:%[^,]+]] = apply [[GET_OWNED]]
397
418
// CHECK: [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]]
398
419
// CHECK: [[COPY:%[^,]+]] = copy_value [[MOVE]]
399
420
// CHECK: [[CALLEE_OWNED_OWNED:%[^,]+]] = function_ref @callee_owned_owned
400
421
// CHECK: apply [[CALLEE_OWNED_OWNED]]([[MOVE]], [[COPY]])
401
422
// CHECK-LABEL: } // end sil function 'fold_single_block_one_apply_double_use_all_owned__no_remaining_uses'
402
- sil [ossa] @fold_single_block_one_apply_double_use_all_owned__no_remaining_uses : $@convention(thin) (@owned C) -> () {
403
- entry(%instance : @owned $C):
423
+ sil [ossa] @fold_single_block_one_apply_double_use_all_owned__no_remaining_uses : $@convention(thin) () -> () {
424
+ entry:
425
+ %get_owned = function_ref @get_owned : $@convention(thin) () -> (@owned C)
426
+ %instance = apply %get_owned() : $@convention(thin) () -> (@owned C)
404
427
%lifetime = begin_borrow [lexical] %instance : $C
405
428
%copy_1 = copy_value %lifetime : $C
406
429
%copy_2 = copy_value %lifetime : $C
@@ -464,7 +487,8 @@ entry(%instance : @owned $C):
464
487
// Fold with the last consuming use but not with a previous consuming use.
465
488
//
466
489
// CHECK-LABEL: sil [ossa] @fold_single_block_two_applies_first_only : {{.*}} {
467
- // CHECK: bb0([[INSTANCE:%[^,]+]] :
490
+ // CHECK: [[GET_OWNED:%[^,]+]] = function_ref @get_owned
491
+ // CHECK: [[INSTANCE:%[^,]+]] = apply [[GET_OWNED]]
468
492
// CHECK: [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]]
469
493
// CHECK: [[LIFETIME:%[^,]+]] = begin_borrow [lexical] [[MOVE]]
470
494
// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
@@ -474,8 +498,9 @@ entry(%instance : @owned $C):
474
498
// CHECK: tuple ()
475
499
// CHECK: apply [[CALLEE_OWNED]]([[MOVE]])
476
500
// CHECK-LABEL: } // end sil function 'fold_single_block_two_applies_first_only'
477
- sil [ossa] @fold_single_block_two_applies_first_only : $@convention(thin) (@owned C) -> () {
478
- entry(%instance : @owned $C):
501
+ sil [ossa] @fold_single_block_two_applies_first_only : $@convention(thin) () -> () {
502
+ %get_owned = function_ref @get_owned : $@convention(thin) () -> (@owned C)
503
+ %instance = apply %get_owned() : $@convention(thin) () -> (@owned C)
479
504
%lifetime = begin_borrow [lexical] %instance : $C
480
505
%callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
481
506
%copy_1 = copy_value %lifetime : $C
@@ -523,23 +548,27 @@ exit:
523
548
// and the lexical scope ends before the use on the non-lexical branch.
524
549
//
525
550
// CHECK-LABEL: sil [ossa] @nofold_two_parallel_owned_uses_one_lexical___scope_ends_before_use : {{.*}} {
526
- // CHECK: {{bb[0-9]+}}([[INSTANCE :%[^,]+]] :
527
- // CHECK: [[COPY :%[^,]+]] = copy_value [[INSTANCE ]]
528
- // CHECK: [[MOVE :%[^,]+]] = move_value [lexical] [[INSTANCE]]
551
+ // CHECK: [[GET_OWNED :%[^,]+]] = function_ref @get_owned
552
+ // CHECK: [[INSTANCE :%[^,]+]] = apply [[GET_OWNED ]]
553
+ // CHECK: [[LIFETIME :%[^,]+]] = begin_borrow [lexical] [[INSTANCE]]
529
554
// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
530
555
// CHECK: cond_br undef, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
531
556
// CHECK: [[LEFT]]:
532
- // CHECK: apply [[CALLEE_OWNED]]([[MOVE]])
533
- // CHECK: destroy_value [[COPY]]
557
+ // CHECK: [[COPY:%[^,]+]] = copy_value [[LIFETIME]]
558
+ // CHECK: apply [[CALLEE_OWNED]]([[COPY]])
559
+ // CHECK: end_borrow [[LIFETIME]]
560
+ // CHECK: destroy_value [[INSTANCE]]
534
561
// CHECK: br [[EXIT:bb[0-9]+]]
535
562
// CHECK: [[RIGHT]]:
536
- // CHECK: destroy_value [[MOVE ]]
537
- // CHECK: apply [[CALLEE_OWNED]]([[COPY ]])
563
+ // CHECK: end_borrow [[LIFETIME ]]
564
+ // CHECK: apply [[CALLEE_OWNED]]([[INSTANCE ]])
538
565
// CHECK: br [[EXIT]]
539
566
// CHECK: [[EXIT]]:
540
567
// CHECK-LABEL: } // end sil function 'nofold_two_parallel_owned_uses_one_lexical___scope_ends_before_use'
541
- sil [ossa] @nofold_two_parallel_owned_uses_one_lexical___scope_ends_before_use : $@convention(thin) (@owned C) -> () {
542
- entry(%instance : @owned $C):
568
+ sil [ossa] @nofold_two_parallel_owned_uses_one_lexical___scope_ends_before_use : $@convention(thin) () -> () {
569
+ entry:
570
+ %get_owned = function_ref @get_owned : $@convention(thin) () -> (@owned C)
571
+ %instance = apply %get_owned() : $@convention(thin) () -> (@owned C)
543
572
%copy_2 = copy_value %instance : $C
544
573
%lifetime = begin_borrow [lexical] %instance : $C
545
574
%callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
@@ -618,7 +647,8 @@ exit:
618
647
// use of %original_borrowee in that unreachable-terminated branch.
619
648
//
620
649
// CHECK-LABEL: sil [ossa] @fold_unreachable : {{.*}} {
621
- // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
650
+ // CHECK: [[GET_OWNED:%[^,]+]] = function_ref @get_owned
651
+ // CHECK: [[INSTANCE:%[^,]+]] = apply [[GET_OWNED]]
622
652
// CHECK: [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]]
623
653
// CHECK: cond_br undef, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
624
654
// CHECK: [[LEFT]]:
@@ -629,8 +659,10 @@ exit:
629
659
// CHECK: br [[EXIT:bb[0-9]+]]
630
660
// CHECK: [[EXIT]]:
631
661
// CHECK-LABEL: } // end sil function 'fold_unreachable'
632
- sil [ossa] @fold_unreachable : $@convention(thin) (@owned C) -> () {
633
- entry(%instance : @owned $C):
662
+ sil [ossa] @fold_unreachable : $@convention(thin) () -> () {
663
+ entry:
664
+ %get_owned = function_ref @get_owned : $@convention(thin) () -> (@owned C)
665
+ %instance = apply %get_owned() : $@convention(thin) () -> (@owned C)
634
666
%lifetime = begin_borrow [lexical] %instance : $C
635
667
cond_br undef, left, right
636
668
0 commit comments