@@ -43,6 +43,9 @@ struct NE: ~Escapable {
4343 init(object: borrowing C) { self.object = copy object }
4444}
4545
46+ sil [ossa] @useCAddress : $@convention(thin) (@inout_aliasable C) -> ()
47+
48+
4649// =============================================================================
4750// LinearLiveness
4851// =============================================================================
@@ -1948,6 +1951,54 @@ bb1(%reborrow2 : @reborrow $D):
19481951 return %99 : $()
19491952}
19501953
1954+ // CHECK-LABEL: partial_apply_noescape_onheap: interior_liveness_swift with: %box, true
1955+ // CHECK: Interior liveness with inner uses: %{{.*}} = alloc_box ${ var C }
1956+ // CHECK-NEXT: Inner scope: %{{.*}} = begin_borrow [lexical] %{{.*}} : ${ var C }
1957+ // CHECK-NEXT: Pointer escape: %{{.*}} = partial_apply [callee_guaranteed] %{{.*}}(%{{.*}}) : $@convention(thin) (@inout_aliasable C) -> ()
1958+ // CHECK-NEXT: begin: %{{.*}} = alloc_box ${ var C }
1959+ // CHECK-NEXT: ends: destroy_value %{{.*}} : ${ var C }
1960+ // CHECK-NEXT: exits:
1961+ // CHECK-NEXT: interiors: end_borrow %{{.*}} : ${ var C }
1962+ // CHECK-NEXT: %{{.*}} = partial_apply [callee_guaranteed] %{{.*}}(%{{.*}}) : $@convention(thin) (@inout_aliasable C) -> ()
1963+ // CHECK-NEXT: %{{.*}} = project_box %{{.*}} : ${ var C }, 0
1964+ // CHECK-NEXT: %{{.*}} = begin_borrow [lexical] %3 : ${ var C }
1965+ // CHECK-NEXT: last user: destroy_value %3 : ${ var C }
1966+ // CHECK-NEXT: partial_apply_noescape_onheap: interior_liveness_swift with: %box, true
1967+ sil [ossa] @partial_apply_noescape_onheap : $@convention(thin) () -> () {
1968+ bb0:
1969+ cond_br undef, bb2, bb1
1970+
1971+ bb1:
1972+ %1 = enum $Optional<@callee_guaranteed () -> ()>, #Optional.none!enumelt
1973+ br bb4(%1)
1974+
1975+ bb2:
1976+ %box = alloc_box ${ var C }
1977+ %borrow = begin_borrow [lexical] %box
1978+ specify_test "interior_liveness_swift %box true"
1979+ %adr = project_box %borrow : ${ var C }, 0
1980+ br bb3
1981+
1982+ bb3:
1983+ %f = function_ref @useCAddress : $@convention(thin) (@inout_aliasable C) -> ()
1984+ %pa1 = partial_apply [callee_guaranteed] %f(%adr) : $@convention(thin) (@inout_aliasable C) -> ()
1985+ %pa2 = copy_value %pa1
1986+ %pane = convert_escape_to_noescape %pa2 : $@callee_guaranteed () -> () to $@noescape @callee_guaranteed () -> ()
1987+ %enum = enum $Optional<@callee_guaranteed () -> ()>, #Optional.some!enumelt, %pa2
1988+ end_borrow %borrow
1989+ destroy_value %box
1990+ destroy_value %pa1
1991+ destroy_value %pane
1992+ br bb4(%enum)
1993+
1994+ bb4(%phi : @owned $Optional<@callee_guaranteed () -> ()>):
1995+ // ClosureLifetimeFixup destroys closures after destroying its addressable captures:
1996+ // this is bad OSSA but still accepted as valid until ClosureLifetimeFixup is rewritten.
1997+ destroy_value %phi
1998+ %r = tuple ()
1999+ return %r
2000+ }
2001+
19512002// =============================================================================
19522003// ExtendedLiveness
19532004// =============================================================================
0 commit comments