blob: bcd8f47a6a4a139e1ba98fe8b8e86779242f73a4 [file] [log] [blame]
// RUN: %target-sil-opt -enable-sil-opaque-values -assume-parsing-unqualified-ownership-sil -function-signature-opts %s | %FileCheck %s
import Builtin
struct R<T> {
var base: T
}
struct S {
var val: Builtin.Int32
}
sil @testAggregateArgHelper : $@convention(thin) (@owned R<S>) -> ()
// Test owned-to-guaranteed transformation of opaque arguments.
//
// CHECK-LABEL: sil [thunk] [always_inline] @testAggregateArg : $@convention(thin) (@in R<S>) -> @out () {
// CHECK: bb0(%0 : $R<S>):
// CHECK: [[F:%.*]] = function_ref @_T016testAggregateArgTf4g_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 @_T016testAggregateArgTf4g_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 '_T016testAggregateArgTf4g_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 : $()
}