File: function_types.sil

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (66 lines) | stat: -rw-r--r-- 3,025 bytes parent folder | download | duplicates (2)
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 : $()
}