1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
// RUN: %swift -disable-legacy-type-info -target x86_64-apple-macosx10.9 -module-name function_types %s -emit-ir -o - | %FileCheck %s
// RUN: %swift -disable-legacy-type-info -target i386-apple-ios7.1 %s -module-name function_types -emit-ir -o - | %FileCheck %s
// RUN: %swift -disable-legacy-type-info -target x86_64-apple-ios7.1 %s -module-name function_types -emit-ir -o - | %FileCheck %s
// RUN: %swift -disable-legacy-type-info -target armv7-apple-ios7.1 %s -module-name function_types -emit-ir -o - | %FileCheck %s
// RUN: %swift -disable-legacy-type-info -target arm64-apple-ios7.1 %s -module-name function_types -emit-ir -o - | %FileCheck %s
// RUN: %swift -disable-legacy-type-info -target x86_64-unknown-linux-gnu -disable-objc-interop %s -module-name function_types -emit-ir -o - | %FileCheck %s
// REQUIRES: CODEGENERATOR=X86
// REQUIRES: CODEGENERATOR=ARM
import Builtin
sil_stage canonical
public protocol Protocol {}
struct S : Protocol {}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc ptr @thin_func_value(ptr %0) {{.*}} {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret ptr %0
// CHECK-NEXT: }
sil @thin_func_value : $@convention(thin) (@convention(thin) () -> ()) -> @convention(thin) () -> () {
entry(%x : $@convention(thin) () -> ()):
return %x : $@convention(thin) () -> ()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc { ptr, ptr } @thick_func_value(ptr %0, ptr %1) {{.*}} {
// CHECK-NEXT: entry:
// CHECK-NEXT: call ptr @swift_retain(ptr returned %1) {{#[0-9]+}}
// CHECK-NEXT: call void @swift_release(ptr %1) {{#[0-9]+}}
// CHECK-NEXT: %3 = insertvalue { ptr, ptr } undef, ptr %0, 0
// CHECK-NEXT: %4 = insertvalue { ptr, ptr } %3, ptr %1, 1
// CHECK-NEXT: ret { ptr, ptr } %4
// CHECK-NEXT: }
sil @thick_func_value : $@convention(thin) (@owned () -> ()) -> @owned () -> () {
entry(%x : $() -> ()):
strong_retain %x : $() -> ()
strong_release %x : $() -> ()
return %x : $() -> ()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc ptr @thin_witness_value(ptr %0) {{.*}} {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret ptr %0
// CHECK-NEXT: }
sil @thin_witness_value : $@convention(thin) (@convention(witness_method: Protocol) (S) -> ()) -> @convention(witness_method: Protocol) (S) -> () {
entry(%x : $@convention(witness_method: Protocol) (S) -> ()):
return %x : $@convention(witness_method: Protocol) (S) -> ()
}
struct X {}
sil @out_void_return : $@convention(thin) () -> @out X
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @use_void_return_value(ptr noalias nocapture sret({{.*}}) %0) {{.*}} {
// CHECK-NEXT: entry:
// CHECK-NEXT: call swiftcc void @out_void_return(ptr noalias nocapture sret({{.*}}) %0)
// CHECK-NEXT: ret void
// CHECK-NEXT: }
sil @use_void_return_value : $@convention(thin) () -> @out X {
entry(%x : $*X):
%f = function_ref @out_void_return : $@convention(thin) () -> @out X
%z = apply %f(%x) : $@convention(thin) () -> @out X
return %z : $()
}
|