blob: 9701b83fcaa6f9f041683cd4765bca7fca805eec [file] [log] [blame]
// RUN: %target-sil-opt -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] [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: [[COPY:%.*]] = copy_value %0 : $R<S>
// CHECK: retain_value %0 : $R<S>
// CHECK: [[F:%.*]] = function_ref @testAggregateArgHelper : $@convention(thin) (@owned R<S>) -> ()
// CHECK: [[CALL:%.*]] = apply [[F]]([[COPY]]) : $@convention(thin) (@owned R<S>) -> ()
// CHECK: destroy_value %0 : $R<S>
// CHECK: return %{{.*}} : $()
// CHECK-LABEL: } // end sil function '$s16testAggregateArgTf4g_n'
sil @testAggregateArg : $@convention(thin) (@in R<S>) -> @out () {
bb0(%0 : $R<S>):
%9 = copy_value %0 : $R<S>
retain_value %0 : $R<S>
%10 = function_ref @testAggregateArgHelper : $@convention(thin) (@owned R<S>) -> ()
%12 = apply %10(%9) : $@convention(thin) (@owned R<S>) -> ()
destroy_value %0 : $R<S>
release_value %0 : $R<S>
%1284 = tuple ()
return %1284 : $()
}