@@ -21,13 +21,16 @@ struct M4: ~Copyable {
2121 let s4: M
2222}
2323
24+ class C {}
25+
2426sil @get_M4 : $@convention(thin) () -> @owned M4
2527sil @end_2 : $@convention(thin) (@owned M, @owned M) -> ()
2628sil @see_addr : $@convention(thin) (@in_guaranteed M) -> ()
2729sil @see_addr_2 : $@convention(thin) (@in_guaranteed M, @in_guaranteed M) -> ()
2830sil @replace_2 : $@convention(thin) (@inout M, @inout M) -> ()
2931sil @get_out_2 : $@convention(thin) () -> (@out M, @out M)
3032sil @take_addr_2 : $@convention(thin) (@in M, @in M) -> ()
33+ sil @getC : $@convention(thin) () -> (@owned C)
3134
3235/// Two non-contiguous fields (#M4.s2, #M4.s4) are borrowed by @see_addr_2.
3336/// Two non-contiguous fields (#M4.s1, #M$.s3) are consumed by @end_2.
@@ -253,3 +256,37 @@ bb0(%0 : @guaranteed $M):
253256 return %retval : $()
254257}
255258
259+ // CHECK-LABEL: sil [ossa] @rdar130427564 : {{.*}} {
260+ // Verify that no instructions were inserted after backedge2's terminator. (In
261+ // fact, if they were, the test would crash.)
262+ // CHECK: bb2([[C0:%[^,]+]] : @owned $C, [[B0:%[^,]+]] : @reborrow @guaranteed $C):
263+ // CHECK-NEXT: end_borrow [[B0]]
264+ // CHECK-NEXT: destroy_value [[C0]]
265+ // CHECK-NEXT: br
266+ // CHECK-LABEL: } // end sil function 'rdar130427564'
267+ sil [ossa] @rdar130427564 : $@convention(thin) (@in_guaranteed M) -> () {
268+ entry(%ignore_me : $*M):
269+ %ignore_me_2 = mark_unresolved_non_copyable_value [no_consume_or_assign] %ignore_me : $*M
270+ br fn
271+ fn:
272+ %getC = function_ref @getC : $@convention(thin) () -> (@owned C)
273+ %c = apply %getC() : $@convention(thin) () -> (@owned C)
274+ %b = begin_borrow %c : $C
275+ br header(%c : $C, %b : $C)
276+ header(%c0 : @owned $C, %b0 : @reborrow @guaranteed $C):
277+ end_borrow %b0 : $C
278+ destroy_value %c0 : $C
279+ br body
280+ body:
281+ br latch
282+ latch:
283+ cond_br undef, backedge, ecit
284+ backedge:
285+ %c1 = apply %getC() : $@convention(thin) () -> (@owned C)
286+ %b1 = begin_borrow %c1 : $C
287+ br backedge2(%c1 : $C, %b1 : $C)
288+ backedge2(%c2 : @owned $C, %b2 : @reborrow @guaranteed $C):
289+ br header(%c2 : $C, %b2 : $C)
290+ ecit:
291+ unreachable
292+ }
0 commit comments