File: extend_lifetime.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 (224 lines) | stat: -rw-r--r-- 7,510 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// RUN: %target-sil-opt \
// RUN:     %s \
// RUN:     -enable-sil-verify-all=0 \
// RUN:     -enable-ossa-verify-complete \
// RUN:     -verify-continue-on-failure \
// RUN:     -sil-ownership-verifier-enable-testing \
// RUN:     -ownership-verifier-textual-error-dumper \
// RUN:     -o /dev/null \
// RUN: 2>&1 | %FileCheck %s
// REQUIRES: asserts

sil_stage canonical

import Builtin

class C {}

// CHECK-LABEL: Begin Error in function invalid__single__usefree_consume__before
// CHECK:       SIL verification failed: extend_lifetime in non-dead-end
// CHECK:       Verifying instruction:
// CHECK:          [[C:%[^,]+]] = argument of bb0
// CHECK:       ->   extend_lifetime [[C]]
// CHECK-LABEL: End Error in function invalid__single__usefree_consume__before
// CHECK-LABEL: Begin Error in function invalid__single__usefree_consume__before
// CHECK:       SIL verification failed: extend_lifetime use within unextended linear liveness boundary
// CHECK:       Verifying instruction:
// CHECK:          [[C]]
// CHECK:       ->   extend_lifetime [[C]]
// CHECK-LABEL: End Error in function invalid__single__usefree_consume__before
// CHECK-LABEL: Begin Error in function invalid__single__usefree_consume__before
// CHECK-LABEL: SIL verification failed: extend_lifetime after last user block
// CHECK:       Verifying instruction:
// CHECK:          [[C]]
// CHECK:       ->   extend_lifetime [[C]]
// CHECK-LABEL: End Error in function invalid__single__usefree_consume__before
sil [ossa] @invalid__single__usefree_consume__before : $@convention(thin) (@owned C) -> () {
entry(%c : @owned $C):
  extend_lifetime %c : $C
  destroy_value %c : $C
  %retval = tuple ()
  return %retval : $()
}

// CHECK-LABEL: Begin Error in function invalid__single__usefree_consume__after
// CHECK:       SIL verification failed: extend_lifetime in non-dead-end
// CHECK:       Verifying instruction:
// CHECK:          [[C:%[^,]+]] = argument of bb0
// CHECK:       ->   extend_lifetime [[C]]
// CHECK-LABEL: End Error in function invalid__single__usefree_consume__after
// CHECK-LABEL: Begin Error in function invalid__single__usefree_consume__after
// CHECK:       SIL verification failed: extend_lifetime after last user block
// CHECK:       Verifying instruction:
// CHECK:          [[C]] = argument of bb0
// CHECK:       ->   extend_lifetime [[C]]
// CHECK-LABEL: End Error in function invalid__single__usefree_consume__after
sil [ossa] @invalid__single__usefree_consume__after : $@convention(thin) (@owned C) -> () {
entry(%c : @owned $C):
  destroy_value %c : $C
  extend_lifetime %c : $C
  %retval = tuple ()
  return %retval : $()
}

// CHECK-LABEL: Begin Error in function invalid__single__usefree_consumefree
// CHECK:       SIL verification failed: extend_lifetime in non-dead-end
// CHECK:       Verifying instruction:
// CHECK:          [[C:%[^,]+]] = argument of bb0
// CHECK:       ->   extend_lifetime [[C]]
// CHECK-LABEL: End Error in function invalid__single__usefree_consumefree
sil [ossa] @invalid__single__usefree_consumefree : $@convention(thin) (@owned C) -> () {
entry(%c : @owned $C):
  extend_lifetime %c : $C
  %retval = tuple ()
  return %retval : $()
}

// CHECK-NOT: valid__loop_conditional__header_uses__after
sil [ossa] @valid__loop_conditional__header_uses__after : $@convention(thin) (@owned C) -> () {
entry(%c : @owned $C):
  cond_br undef, exit, header

header:
  %b = begin_borrow %c : $C
  end_borrow %b : $C
  extend_lifetime %c : $C
  br loop

loop:
  br loop

exit:
  destroy_value %c : $C
  %retval = tuple ()
  return %retval : $()
}

// CHECK-LABEL: Error#: 0. Begin Error in Function: 'invalid__loop_conditional__header_uses__before'
// CHECK:       Found outside of lifetime use!
// CHECK:       Value: [[C:%[^,]+]] = argument of bb0
// CHECK:       User:  [[B:%[^,]+]] = begin_borrow [[C]]
// CHECK-LABEL: Error#: 0. End Error in Function: 'invalid__loop_conditional__header_uses__before'
// CHECK-LABEL: Error#: 1. Begin Error in Function: 'invalid__loop_conditional__header_uses__before'
// CHECK:       Found outside of lifetime use!
// CHECK:       Value: [[C]]
// CHECK:       User:  end_borrow [[B]]
// CHECK-LABEL: Error#: 1. End Error in Function: 'invalid__loop_conditional__header_uses__before'
// CHECK-NOT: invalid__loop_conditional__header_uses__before
sil [ossa] @invalid__loop_conditional__header_uses__before : $@convention(thin) (@owned C) -> () {
entry(%c : @owned $C):
  cond_br undef, exit, header

header:
  extend_lifetime %c : $C
  %b = begin_borrow %c : $C
  end_borrow %b : $C
  br loop

loop:
  br loop

exit:
  destroy_value %c : $C
  %retval = tuple ()
  return %retval : $()
}

sil [ossa] @invalid__loop_conditional__header_uses__between : $@convention(thin) (@owned C) -> () {
entry(%c : @owned $C):
  cond_br undef, exit, header

header:
  %b = begin_borrow %c : $C
  extend_lifetime %c : $C
  end_borrow %b : $C
  br loop

loop:
  br loop

exit:
  destroy_value %c : $C
  %retval = tuple ()
  return %retval : $()
}

// CHECK-NOT: valid__loop_conditional__loop_uses__after
sil [ossa] @valid__loop_conditional__loop_uses__after : $@convention(thin) (@owned C) -> () {
entry(%c : @owned $C):
  cond_br undef, exit, header

header:
  br loop

loop:
  %b = begin_borrow %c : $C
  end_borrow %b : $C
  extend_lifetime %c : $C
  br loop

exit:
  destroy_value %c : $C
  %retval = tuple ()
  return %retval : $()
}

// TODO: Maybe this should be allowed.
// CHECK-LABEL: Error#: 0. Begin Error in Function: 'invalid__loop_conditional__loop_uses__before'
// CHECK:       Found outside of lifetime use!
// CHECK:       Value: [[C:%[^,]+]] = argument of bb0
// CHECK:       User:  [[B:%[^,]+]] = begin_borrow [[C]]
// CHECK-LABEL: Error#: 0. End Error in Function: 'invalid__loop_conditional__loop_uses__before'
// CHECK-LABEL: Error#: 1. Begin Error in Function: 'invalid__loop_conditional__loop_uses__before'
// CHECK:       Found outside of lifetime use!
// CHECK:       Value: [[C]] = argument of bb0
// CHECK:       User:  end_borrow [[B]]
// CHECK-LABEL: Error#: 1. End Error in Function: 'invalid__loop_conditional__loop_uses__before'
sil [ossa] @invalid__loop_conditional__loop_uses__before : $@convention(thin) (@owned C) -> () {
entry(%c : @owned $C):
  cond_br undef, exit, header

header:
  br loop

loop:
  extend_lifetime %c : $C
  %b = begin_borrow %c : $C
  end_borrow %b : $C
  br loop

exit:
  destroy_value %c : $C
  %retval = tuple ()
  return %retval : $()
}

// TODO: Maybe this should be allowed.
// CHECK-LABEL: Error#: 0. Begin Error in Function: 'invalid__loop_conditional__loop_uses__between'
// CHECK:       Found outside of lifetime use!
// CHECK:       Value: [[C:%[^,]+]] = argument of bb0
// CHECK:       User:  [[B:%[^,]+]] = begin_borrow [[C]]
// CHECK-LABEL: Error#: 0. End Error in Function: 'invalid__loop_conditional__loop_uses__between'
// CHECK-LABEL: Error#: 1. Begin Error in Function: 'invalid__loop_conditional__loop_uses__between'
// CHECK:       Found outside of lifetime use!
// CHECK:       Value: [[C]] = argument of bb0
// CHECK:       User:  end_borrow [[B]]
// CHECK-LABEL: Error#: 1. End Error in Function: 'invalid__loop_conditional__loop_uses__between'
sil [ossa] @invalid__loop_conditional__loop_uses__between : $@convention(thin) (@owned C) -> () {
entry(%c : @owned $C):
  cond_br undef, exit, header

header:
  br loop

loop:
  %b = begin_borrow %c : $C
  extend_lifetime %c : $C
  end_borrow %b : $C
  br loop

exit:
  destroy_value %c : $C
  %retval = tuple ()
  return %retval : $()
}