mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The intent for `@inline(always)` is to act as an optimization control. The user can rely on inlining to happen or the compiler will emit an error message. Because function values can be dynamic (closures, protocol/class lookup) this guarantee can only be upheld for direct function references. In cases where the optimizer can resolve dynamic function values the attribute shall be respected. rdar://148608854
61 lines
2.5 KiB
Plaintext
61 lines
2.5 KiB
Plaintext
// RUN: %target-sil-opt %s -verify -closure-specialize -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] @$s26closure_specialize_fragile6actionyyF : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = tuple ()
|
|
return %0 : $()
|
|
} // end sil function '$s26closure_specialize_fragile6actionyyF'
|
|
|
|
// CHECK-LABEL: sil [serialized] [heuristic_always_inline] @$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] @$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 @$s26closure_specialize_fragile15resilientCalleeyyyc2fn_tF : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
|
|
|
|
// resilientCallee(fn:)
|
|
sil @$s26closure_specialize_fragile15resilientCalleeyyyc2fn_tF : $@convention(thin) (@owned @callee_owned () -> ()) -> () {
|
|
bb0(%0 : $@callee_owned () -> ()):
|
|
strong_retain %0 : $@callee_owned () -> ()
|
|
%3 = apply %0() : $@callee_owned () -> ()
|
|
strong_release %0 : $@callee_owned () -> ()
|
|
%5 = tuple ()
|
|
return %5 : $()
|
|
} // end sil function '$s26closure_specialize_fragile15resilientCalleeyyyc2fn_tF'
|
|
|
|
// closure #1 in fragileCaller()
|
|
sil shared [serialized] @$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_'
|