File: public_external.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 (127 lines) | stat: -rw-r--r-- 4,775 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// RUN: %target-swift-frontend %s -parse-sil -emit-module -module-name Swift -module-link-name swiftCore -parse-stdlib -parse-as-library -o - | %target-sil-opt -module-name Swift -emit-sorted-sil | %FileCheck %s

sil_stage raw
import Builtin

// Check that bodies are not serialized for external functions.
// CHECK-NOT: sil{{.*}}@pe : $@convention(thin) () -> () {
// CHECK-NOT: sil{{.*}}@external_pe : $@convention(thin) () -> () {
// CHECK-NOT: sil{{.*}}@he : $@convention(thin) () -> () {
// CHECK-NOT: sil{{.*}}@external_he : $@convention(thin) () -> () {
// CHECK-NOT: sil{{.*}}@se : $@convention(thin) () -> () {

// Check that declarations are not serialized for external functions that are
// not used, i.e. not referenced from serialized functions.
// CHECK-NOT: sil{{.*}}@pe : $@convention(thin) () -> ()
// CHECK-NOT: sil{{.*}}@external_pe : $@convention(thin) () -> ()
// CHECK-NOT: sil{{.*}}@he : $@convention(thin) () -> ()
// CHECK-NOT: sil{{.*}}@external_he : $@convention(thin) () -> ()
// CHECK-NOT: sil{{.*}}@se : $@convention(thin) () -> ()

// Check that declarations for shared external functions are not serialized,
// because such functions should always have a serialized body.
// CHECK-NOT: sil{{.*}}@se : $@convention(thin) () -> ()

// Some functions are marked transparent to prevent ExternalDefsToDecls opt from
// converting them into declarations.

sil public_external [serialized] @pe : $@convention(thin) () -> () {
  %0 = tuple()
  return %0 : $()
}

sil public_external [serialized] [transparent] @transparent_pe : $@convention(thin) () -> () {
  %0 = tuple()
  return %0 : $()
}

sil hidden @he : $@convention(thin) () -> () {
  %0 = tuple()
  return %0 : $()
}

sil hidden [transparent] @tranparent_he : $@convention(thin) () -> () {
  %0 = tuple()
  return %0 : $()
}

sil shared @se : $@convention(thin) () -> () {
  %0 = tuple()
  return %0 : $()
}

// Check that external non-shared functions are serialized only
// if they are referenced from something reachable from non-external functions.
// Since all these fN functions are referenced only from an external function,
// do not serialize even their declarations.

// CHECK-NOT: sil{{.*}}@fn1 : $@convention(thin) () -> ()
sil public_external [serialized] [noinline] @fn1 : $@convention(thin) () -> () {
  %0 = tuple()
  return %0 : $()
}

// CHECK-NOT: sil{{.*}}@fn2: $@convention(thin) () -> ()
sil public_external [serialized] [noinline] @fn2 : $@convention(thin) () -> () {
  %0 = tuple()
  return %0 : $()
}

// CHECK-NOT: sil{{.*}}@fn3 : $@convention(thin) () -> ()
sil public_external [serialized] [noinline] @fn3 : $@convention(thin) () -> () {
  %0 = tuple()
  return %0 : $()
}

// CHECK-NOT: sil{{.*}}@fn4 : $@convention(thin) () -> ()
sil public_external [serialized] [noinline] @fn4 : $@convention(thin) () -> () {
  %0 = tuple()
  return %0 : $()
}

// Emit the declaration of this function, because it is referenced from serialized
// function use_external_functions.
sil public_external [serialized] [noinline] @used_external_fn : $@convention(thin) () -> () {
  %0 = tuple()
  return %0 : $()
}

// Do not serialize the body of this function, because it is public external.
// But emit its declaration, because it is referenced from a body of serialized
// fragile function.

// There should be no body for this function.
// CHECK-NOT: sil{{.*}}@public_external_fn : $@convention(thin) () -> () {
// But declaration should be present.
// CHECK: sil{{.*}}@public_external_fn : $@convention(thin) () -> ()
sil public_external [serialized] [noinline] @public_external_fn : $@convention(thin) () -> () {
  %0 = function_ref @fn1 : $@convention(thin) () -> ()
  %1 = apply %0 () : $@convention(thin) () -> ()
  %2 = function_ref @fn2 : $@convention(thin) () -> ()
  %3 = apply %2 () : $@convention(thin) () -> ()
  %4 = function_ref @fn3 : $@convention(thin) () -> ()
  %5 = apply %4 () : $@convention(thin) () -> ()
  %6 = function_ref @fn4 : $@convention(thin) () -> ()
  %7 = apply %6 () : $@convention(thin) () -> ()

  %10 = tuple()
  return %10 : $()
}

// The body of this fragile function has to be emitted.
// CHECK-LABEL: sil{{.*}}@use_external_functions : $@convention(thin) () -> () {
sil [serialized] @use_external_functions: $@convention(thin) () -> () {
  %0 = function_ref @public_external_fn : $@convention(thin) () -> ()
  %1 = apply %0 () : $@convention(thin) () -> ()

  %2 = function_ref @used_external_fn : $@convention(thin) () -> ()
  %3 = apply %2 () : $@convention(thin) () -> ()

  %4 = tuple()
  return %4 : $()
}

// There should be no body for this function.
// CHECK-NOT: sil{{.*}}@used_external_fn : $@convention(thin) () -> () {
// But declaration should be present.
// CHECK: sil{{.*}}@used_external_fn : $@convention(thin) () -> ()