@@ -28,13 +28,15 @@ sil [ossa] @get_owned : $@convention(thin) () -> @owned C
2828// with an apply.
2929//
3030// 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]]
3233// CHECK: [[CALEE_OWNED:%[^,]+]] = function_ref @callee_owned
3334// CHECK: [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]]
3435// CHECK: apply [[CALEE_OWNED]]([[MOVE]])
3536// 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)
3840 %callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
3941 %lifetime = begin_borrow [lexical] %instance : $C
4042 %copy = copy_value %lifetime : $C
@@ -83,7 +85,8 @@ entry(%instance : @owned $C):
8385// borrowee intact on other paths.
8486//
8587// 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]]
8790// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
8891// CHECK: cond_br undef, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
8992// CHECK: [[LEFT]]:
@@ -95,8 +98,10 @@ entry(%instance : @owned $C):
9598// CHECK: br [[EXIT]]
9699// CHECK: [[EXIT]]:
97100// 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)
100105 %callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
101106 cond_br undef, left, right
102107
@@ -122,7 +127,8 @@ exit:
122127// independents owned lexical scopes.
123128//
124129// 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]]
126132// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
127133// CHECK: cond_br undef, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
128134// CHECK: [[LEFT]]:
@@ -135,8 +141,10 @@ exit:
135141// CHECK: br [[EXIT]]
136142// CHECK: [[EXIT]]:
137143// 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)
140148 %callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
141149 cond_br undef, left, right
142150
@@ -211,7 +219,8 @@ exit:
211219// within a single owned lexical scope.
212220//
213221// 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]]
215224// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
216225// CHECK: [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]] : $C
217226// CHECK: cond_br undef, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
@@ -223,8 +232,10 @@ exit:
223232// CHECK: br [[EXIT]]
224233// CHECK: [[EXIT]]:
225234// 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)
228239 %callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
229240 %lifetime = begin_borrow [lexical] %instance : $C
230241 cond_br undef, left, right
@@ -253,7 +264,8 @@ exit:
253264// borrowee that is not within the scope.
254265//
255266// 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]]
257269// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
258270// CHECK: cond_br undef, [[LEFT1:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
259271// CHECK: [[LEFT1]]:
@@ -270,8 +282,10 @@ exit:
270282// CHECK: br [[EXIT]]
271283// CHECK: [[EXIT]]:
272284// 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)
275289 %callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
276290 cond_br undef, left1, right
277291
@@ -306,7 +320,8 @@ exit:
306320// borrowee that is not within the scope.
307321//
308322// 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]]
310325// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
311326// CHECK: cond_br undef, [[LEFT1:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
312327// CHECK: [[LEFT1]]:
@@ -324,8 +339,10 @@ exit:
324339// CHECK: br [[EXIT]]
325340// CHECK: [[EXIT]]:
326341// 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)
329346 %callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
330347 cond_br undef, left1, right
331348
@@ -364,7 +381,8 @@ exit:
364381// guaranteed lifetime remains.
365382//
366383// 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]]
368386// CHECK: [[LIFETIME:%[^,]+]] = move_value [lexical] [[INSTANCE]]
369387// CHECK: [[LIFETIME_GUARANTEED:%[^,]+]] = begin_borrow [lexical] [[LIFETIME]]
370388// CHECK: [[CALLEE_GUARANTEED:%[^,]+]] = function_ref @callee_guaranteed
@@ -374,8 +392,10 @@ exit:
374392// CHECK: [[CALLEE_OWNED_OWNED:%[^,]+]] = function_ref @callee_owned_owned
375393// CHECK: apply [[CALLEE_OWNED_OWNED]]([[LIFETIME]], [[COPY]])
376394// 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)
379399 %lifetime = begin_borrow [lexical] %instance : $C
380400 %callee_guaranteed = function_ref @callee_guaranteed : $@convention(thin) (@guaranteed C) -> ()
381401 apply %callee_guaranteed(%lifetime) : $@convention(thin) (@guaranteed C) -> ()
@@ -393,14 +413,17 @@ entry(%instance : @owned $C):
393413// guaranteed lifetime remains.
394414//
395415// 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]]
397418// CHECK: [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]]
398419// CHECK: [[COPY:%[^,]+]] = copy_value [[MOVE]]
399420// CHECK: [[CALLEE_OWNED_OWNED:%[^,]+]] = function_ref @callee_owned_owned
400421// CHECK: apply [[CALLEE_OWNED_OWNED]]([[MOVE]], [[COPY]])
401422// 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)
404427 %lifetime = begin_borrow [lexical] %instance : $C
405428 %copy_1 = copy_value %lifetime : $C
406429 %copy_2 = copy_value %lifetime : $C
@@ -464,7 +487,8 @@ entry(%instance : @owned $C):
464487// Fold with the last consuming use but not with a previous consuming use.
465488//
466489// 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]]
468492// CHECK: [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]]
469493// CHECK: [[LIFETIME:%[^,]+]] = begin_borrow [lexical] [[MOVE]]
470494// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
@@ -474,8 +498,9 @@ entry(%instance : @owned $C):
474498// CHECK: tuple ()
475499// CHECK: apply [[CALLEE_OWNED]]([[MOVE]])
476500// 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)
479504 %lifetime = begin_borrow [lexical] %instance : $C
480505 %callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
481506 %copy_1 = copy_value %lifetime : $C
@@ -523,23 +548,27 @@ exit:
523548// and the lexical scope ends before the use on the non-lexical branch.
524549//
525550// 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]]
529554// CHECK: [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
530555// CHECK: cond_br undef, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
531556// 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]]
534561// CHECK: br [[EXIT:bb[0-9]+]]
535562// CHECK: [[RIGHT]]:
536- // CHECK: destroy_value [[MOVE ]]
537- // CHECK: apply [[CALLEE_OWNED]]([[COPY ]])
563+ // CHECK: end_borrow [[LIFETIME ]]
564+ // CHECK: apply [[CALLEE_OWNED]]([[INSTANCE ]])
538565// CHECK: br [[EXIT]]
539566// CHECK: [[EXIT]]:
540567// 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)
543572 %copy_2 = copy_value %instance : $C
544573 %lifetime = begin_borrow [lexical] %instance : $C
545574 %callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
@@ -618,7 +647,8 @@ exit:
618647// use of %original_borrowee in that unreachable-terminated branch.
619648//
620649// 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]]
622652// CHECK: [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]]
623653// CHECK: cond_br undef, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
624654// CHECK: [[LEFT]]:
@@ -629,8 +659,10 @@ exit:
629659// CHECK: br [[EXIT:bb[0-9]+]]
630660// CHECK: [[EXIT]]:
631661// 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)
634666 %lifetime = begin_borrow [lexical] %instance : $C
635667 cond_br undef, left, right
636668
0 commit comments