mirror of
https://github.com/apple/swift.git
synced 2026-02-27 18:26:24 +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
29 lines
1.2 KiB
Plaintext
29 lines
1.2 KiB
Plaintext
// RUN: %target-sil-opt -enable-sil-verify-all %s -inline -dce -sil-inline-threshold=1 | %FileCheck %s
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
|
|
// CHECK-LABEL: @caller_of_noinline
|
|
sil @caller_of_noinline : $@convention(thin) () -> () {
|
|
bb0:
|
|
// CHECK-NOT: function_ref @noinline_callee
|
|
// CHECK-NOT: apply
|
|
%0 = function_ref @noinline_callee : $@convention(thin) (Builtin.Int64) -> Builtin.Int64
|
|
%2 = integer_literal $Builtin.Int64, 0
|
|
%3 = apply %0(%2) : $@convention(thin) (Builtin.Int64) -> Builtin.Int64
|
|
%4 = tuple ()
|
|
return %4 : $()
|
|
}
|
|
// CHECK-LABEL: [heuristic_always_inline] @noinline_callee
|
|
sil [heuristic_always_inline] @noinline_callee : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
|
|
bb0(%0 : $Builtin.Int64):
|
|
%2 = integer_literal $Builtin.Int1, 0
|
|
%3 = builtin "umul_with_overflow_Int64"(%0 : $Builtin.Int64, %0 : $Builtin.Int64, %2 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1)
|
|
%4 = tuple_extract %3 : $(Builtin.Int64, Builtin.Int1), 0
|
|
%5 = builtin "umul_with_overflow_Int64"(%4 : $Builtin.Int64, %4 : $Builtin.Int64, %2 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1)
|
|
%6 = tuple_extract %5 : $(Builtin.Int64, Builtin.Int1), 0
|
|
return %6 : $Builtin.Int64
|
|
}
|
|
|