// RUN: %target-sil-opt %s -verify -closure-specialization -o - | %FileCheck %s // Make sure we do not specialize resilientCallee. sil_stage canonical import Builtin import Swift import SwiftShims @_optimize(none) public func action() @inline(__always) public func fragileCaller() public func resilientCallee(fn: () -> ()) // action() sil [Onone] [ossa] @$s26closure_specialize_fragile6actionyyF : $@convention(thin) () -> () { bb0: %0 = tuple () return %0 : $() } // end sil function '$s26closure_specialize_fragile6actionyyF' // CHECK-LABEL: sil [serialized] [heuristic_always_inline] [ossa] @$s26closure_specialize_fragile0C6CalleryyF : $@convention(thin) () -> () // CHECK: function_ref @$s26closure_specialize_fragile15resilientCalleeyyyc2fn_tF : $@convention(thin) (@owned @callee_owned () -> ()) -> () // CHECK: return // fragileCaller() sil [serialized] [heuristic_always_inline] [ossa] @$s26closure_specialize_fragile0C6CalleryyF : $@convention(thin) () -> () { bb0: // function_ref resilientCallee(fn:) %0 = function_ref @$s26closure_specialize_fragile15resilientCalleeyyyc2fn_tF : $@convention(thin) (@owned @callee_owned () -> ()) -> () // function_ref closure #1 in fragileCaller() %1 = function_ref @$s26closure_specialize_fragile0C6CalleryyFyycfU_ : $@convention(thin) () -> () %2 = thin_to_thick_function %1 : $@convention(thin) () -> () to $@callee_owned () -> () %3 = apply %0(%2) : $@convention(thin) (@owned @callee_owned () -> ()) -> () %4 = tuple () return %4 : $() } // end sil function '$s26closure_specialize_fragile0C6CalleryyF' // CHECK-LABEL: sil [ossa] @$s26closure_specialize_fragile15resilientCalleeyyyc2fn_tF : $@convention(thin) (@owned @callee_owned () -> ()) -> () // resilientCallee(fn:) sil [ossa] @$s26closure_specialize_fragile15resilientCalleeyyyc2fn_tF : $@convention(thin) (@owned @callee_owned () -> ()) -> () { bb0(%0 : @owned $@callee_owned () -> ()): %1 = copy_value %0 %3 = apply %1() : $@callee_owned () -> () destroy_value %0 %5 = tuple () return %5 : $() } // end sil function '$s26closure_specialize_fragile15resilientCalleeyyyc2fn_tF' // closure #1 in fragileCaller() sil shared [serialized] [ossa] @$s26closure_specialize_fragile0C6CalleryyFyycfU_ : $@convention(thin) () -> () { bb0: // function_ref action() %0 = function_ref @$s26closure_specialize_fragile6actionyyF : $@convention(thin) () -> () %1 = apply %0() : $@convention(thin) () -> () %2 = tuple () return %2 : $() } // end sil function '$s26closure_specialize_fragile0C6CalleryyFyycfU_'