Files
swift-mirror/test/SILOptimizer/funcsig_opaque.sil
Arnold Schwaighofer 25a071efc8 Add experimental feature @inline(always)
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
2025-09-30 08:36:26 -07:00

41 lines
1.6 KiB
Plaintext

// RUN: %target-sil-opt -sil-print-types -enable-sil-opaque-values -function-signature-opts %s | %FileCheck %s
import Builtin
struct R<T> {
var base: T
}
struct S {
var val: Builtin.NativeObject
}
sil @testAggregateArgHelper : $@convention(thin) (@owned R<S>) -> ()
// Test owned-to-guaranteed transformation of opaque arguments.
//
// CHECK-LABEL: sil [signature_optimized_thunk] [heuristic_always_inline] @testAggregateArg : $@convention(thin) (@in R<S>) -> @out () {
// CHECK: bb0(%0 : $R<S>):
// CHECK: [[F:%.*]] = function_ref @$s16testAggregateArgTf4g_n : $@convention(thin) (@in_guaranteed R<S>) -> @out ()
// CHECK: [[CALL:%.*]] = apply [[F]](%0) : $@convention(thin) (@in_guaranteed R<S>) -> @out ()
// CHECK: release_value %0 : $R<S>
// CHECK: return [[CALL]] : $()
// CHECK-LABEL: } // end sil function 'testAggregateArg'
//
// CHECK-LABEL: sil shared @$s16testAggregateArgTf4g_n : $@convention(thin) (@in_guaranteed R<S>) -> @out () {
// CHECK: bb0(%0 : $R<S>):
// CHECK: retain_value %0 : $R<S>
// CHECK: [[F:%.*]] = function_ref @testAggregateArgHelper : $@convention(thin) (@owned R<S>) -> ()
// CHECK: [[CALL:%.*]] = apply [[F]](%0) : $@convention(thin) (@owned R<S>) -> ()
// CHECK: return %{{.*}} : $()
// CHECK-LABEL: } // end sil function '$s16testAggregateArgTf4g_n'
sil @testAggregateArg : $@convention(thin) (@in R<S>) -> @out () {
bb0(%0 : $R<S>):
retain_value %0 : $R<S>
%10 = function_ref @testAggregateArgHelper : $@convention(thin) (@owned R<S>) -> ()
%12 = apply %10(%0) : $@convention(thin) (@owned R<S>) -> ()
release_value %0 : $R<S>
%1284 = tuple ()
return %1284 : $()
}