File: function_types.sil

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (66 lines) | stat: -rw-r--r-- 3,025 bytes parent folder | download
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 : $()
}