@@ -19,6 +19,7 @@ class ContainsKlass {
1919sil @getKlass : $@convention(thin) () -> @owned Klass
2020sil @getContainsKlass : $@convention(thin) () -> @owned ContainsKlass
2121sil @useIndirect : $@convention(thin) <T> (@in_guaranteed T) -> ()
22+ sil @sideEffect : $@convention(thin) () -> ()
2223
2324//===----------------------------------------------------------------------===//
2425// MARK: Tests
@@ -113,3 +114,37 @@ bb0:
113114 %13 = tuple ()
114115 return %13 : $()
115116}
117+
118+ sil [thunk] @test_reabstraction_thunk : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> @out ()
119+
120+ // CHECK-LABEL: begin running test {{.*}} of {{.*}} on handle_function_conversion_reabstraction_thunks: variable-name-inference with: @trace[0]
121+ // CHECK: Name: 'namedClosure'
122+ // CHECK: Root: %0 = alloc_stack [lexical] $@callee_guaranteed () -> (), var, name "namedClosure"
123+ // CHECK: end running test {{.*}} of {{.*}} on handle_function_conversion_reabstraction_thunks: variable-name-inference with: @trace[0]
124+ sil [ossa] @handle_function_conversion_reabstraction_thunks : $@convention(thin) () -> () {
125+ bb0:
126+ specify_test "variable-name-inference @trace[0]"
127+ %namedStack = alloc_stack [lexical] $@callee_guaranteed () -> (), var, name "namedClosure"
128+ %f = function_ref @sideEffect : $@convention(thin) () -> ()
129+ %pa = partial_apply [callee_guaranteed] %f() : $@convention(thin) () -> ()
130+ store %pa to [init] %namedStack : $*@callee_guaranteed () -> ()
131+
132+ %temp = alloc_stack $@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <()>
133+ %access = begin_access [read] [static] %namedStack : $*@callee_guaranteed () -> ()
134+ %load = load [copy] %access : $*@callee_guaranteed () -> ()
135+ end_access %access : $*@callee_guaranteed () -> ()
136+
137+ %reabstract = function_ref @test_reabstraction_thunk : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> @out ()
138+ %reabstract_partially_applied = partial_apply [callee_guaranteed] %reabstract(%load) : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> @out ()
139+ %cvt = convert_function %reabstract_partially_applied : $@callee_guaranteed () -> @out () to $@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <()>
140+ store %cvt to [init] %temp : $*@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <()>
141+ debug_value [trace] %temp : $*@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <()>
142+
143+ destroy_addr %temp : $*@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <()>
144+ dealloc_stack %temp : $*@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <()>
145+ destroy_addr %namedStack : $*@callee_guaranteed () -> ()
146+ dealloc_stack %namedStack : $*@callee_guaranteed () -> ()
147+
148+ %9999 = tuple ()
149+ return %9999 : $()
150+ }
0 commit comments