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
36 lines
1.2 KiB
Plaintext
36 lines
1.2 KiB
Plaintext
// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -early-inline -sil-inline-threshold=50 | %FileCheck %s
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
import SwiftShims
|
|
|
|
|
|
//CHECK-LABEL: sil @caller_function
|
|
//CHECK-NOT: try_apply
|
|
sil @caller_function : $@convention(thin) () -> @error Error {
|
|
bb0:
|
|
// function_ref main.inner () throws -> ()
|
|
%0 = function_ref @callee_function : $@convention(thin) () -> @error Error // user: %1
|
|
try_apply %0() : $@convention(thin) () -> @error Error, normal bb1, error bb2 // id: %1
|
|
|
|
bb1(%2 : $()): // Preds: bb0
|
|
%3 = tuple () // user: %4
|
|
return %3 : $() // id: %4
|
|
|
|
bb2(%5 : $Error): // Preds: bb0
|
|
throw %5 : $Error // id: %6
|
|
}
|
|
|
|
//CHECK-LABEL: sil [heuristic_always_inline] @callee_function
|
|
//CHECK: return
|
|
|
|
// main.inner () throws -> ()
|
|
sil [heuristic_always_inline] @callee_function : $@convention(thin) () -> @error Error {
|
|
bb0:
|
|
%0 = tuple () // user: %1
|
|
return %0 : $() // id: %1
|
|
}
|
|
|