@@ -18,54 +18,81 @@ struct PairC {
18
18
var second: C
19
19
}
20
20
21
- class C {}
21
+ class C {
22
+ var field: C
23
+ }
22
24
23
25
class D : C {}
24
26
27
+ sil @coro : $@yield_once @convention(thin) () -> @yields @guaranteed C
28
+
25
29
// The introducer of an introducer is always itself.
26
30
27
- // CHECK-LABEL: introducer_identity: find-borrow-introducers with: @trace[0]
31
+ // CHECK-LABEL: introducer_identity: find-borrow-introducers with: %0
28
32
// CHECK: } // end sil function 'introducer_identity'
29
33
// CHECK: Introducers:
30
34
// CHECK-NEXT: %0 = argument of bb0 : $C
31
- // CHECK-NEXT: introducer_identity: find-borrow-introducers with: @trace[0]
35
+ // CHECK-NEXT: introducer_identity: find-borrow-introducers with: %0
36
+
37
+ // CHECK-LABEL: introducer_identity: borrow_introducers with: %0
38
+ // CHECK: } // end sil function 'introducer_identity'
39
+ // CHECK: Borrow introducers for: %0 = argument of bb0 : $C
40
+ // CHECK-NEXT: %0 = argument of bb0 : $C
41
+ // CHECK-NEXT: introducer_identity: borrow_introducers with: %0
32
42
33
- // CHECK-LABEL: introducer_identity: find-borrow-introducers with: @trace[1]
43
+ // CHECK-LABEL: introducer_identity: find-borrow-introducers with: %borrow1
34
44
// CHECK: } // end sil function 'introducer_identity'
35
45
// CHECK: Introducers:
36
46
// CHECK-NEXT: begin_borrow %0 : $C
37
- // CHECK-NEXT: introducer_identity: find-borrow-introducers with: @trace[1]
47
+ // CHECK-NEXT: introducer_identity: find-borrow-introducers with: %borrow1
38
48
39
- // CHECK-LABEL: introducer_identity: find-borrow-introducers with: @trace[2]
49
+ // CHECK-LABEL: introducer_identity: borrow_introducers with: %borrow1
50
+ // CHECK: } // end sil function 'introducer_identity'
51
+ // CHECK: Borrow introducers for: %{{.*}} = begin_borrow %0 : $C
52
+ // CHECK-NEXT: begin_borrow %0 : $C
53
+ // CHECK-NEXT: introducer_identity: borrow_introducers with: %borrow1
54
+
55
+ // CHECK-LABEL: introducer_identity: find-borrow-introducers with: %borrow2
40
56
// CHECK: } // end sil function 'introducer_identity'
41
57
// CHECK: Introducers:
42
58
// CHECK-NEXT: load_borrow %1 : $*C
43
- // CHECK-NEXT: introducer_identity: find-borrow-introducers with: @trace[2]
59
+ // CHECK-NEXT: introducer_identity: find-borrow-introducers with: %borrow2
60
+
61
+ // CHECK-LABEL: introducer_identity: borrow_introducers with: %borrow2
62
+ // CHECK: } // end sil function 'introducer_identity'
63
+ // CHECK: Borrow introducers for: {{.*}} = load_borrow %1 : $*C
64
+ // CHECK-NEXT: load_borrow %1 : $*C
65
+ // CHECK-NEXT: introducer_identity: borrow_introducers with: %borrow2
44
66
45
- // CHECK-LABEL: introducer_identity: find-borrow-introducers with: @trace[3]
67
+ // CHECK-LABEL: introducer_identity: find-borrow-introducers with: %reborrow
46
68
// CHECK: } // end sil function 'introducer_identity'
47
69
// CHECK: Introducers:
48
70
// CHECK-NEXT: argument of bb1 : $C
49
- // CHECK-NEXT: introducer_identity: find-borrow-introducers with: @trace[3]
71
+ // CHECK-NEXT: introducer_identity: find-borrow-introducers with: %reborrow
50
72
73
+ // CHECK-LABEL: introducer_identity: borrow_introducers with: %reborrow
74
+ // CHECK: } // end sil function 'introducer_identity'
75
+ // CHECK: Borrow introducers for: %{{.*}} = argument of bb1 : $C
76
+ // CHECK-NEXT: argument of bb1 : $C
77
+ // CHECK-NEXT: introducer_identity: borrow_introducers with: %reborrow
51
78
sil [ossa] @introducer_identity : $@convention(thin) (@guaranteed C, @in C) -> () {
52
79
entry(%0 : @guaranteed $C, %1 : $*C):
53
- specify_test "find-borrow-introducers @trace[0] "
54
- debug_value [trace] %0 : $C
80
+ specify_test "find-borrow-introducers %0 "
81
+ specify_test "borrow_introducers %0"
55
82
%borrow1 = begin_borrow %0 : $C
56
- specify_test "find-borrow-introducers @trace[1] "
57
- debug_value [trace] %borrow1 : $C
83
+ specify_test "find-borrow-introducers %borrow1 "
84
+ specify_test "borrow_introducers %borrow1"
58
85
59
86
%borrow2 = load_borrow %1 : $*C
60
- specify_test "find-borrow-introducers @trace[2] "
61
- debug_value [trace] %borrow2 : $C
87
+ specify_test "find-borrow-introducers %borrow2 "
88
+ specify_test "borrow_introducers %borrow2"
62
89
end_borrow %borrow2 : $C
63
90
64
91
br exit(%borrow1 : $C)
65
92
66
93
exit(%reborrow : @guaranteed $C):
67
- specify_test "find-borrow-introducers @trace[3] "
68
- debug_value [trace] %reborrow : $C
94
+ specify_test "find-borrow-introducers %reborrow "
95
+ specify_test "borrow_introducers %reborrow"
69
96
end_borrow %reborrow : $C
70
97
destroy_addr %1 : $*C
71
98
%retval = tuple ()
@@ -75,19 +102,24 @@ exit(%reborrow : @guaranteed $C):
75
102
// There is no introducer if the guaranteed value is produced from a
76
103
// trivial value.
77
104
78
- // CHECK-LABEL: introducer_trivial: find-borrow-introducers with: @trace[0]
105
+ // CHECK-LABEL: introducer_trivial: find-borrow-introducers with: %phi
79
106
// CHECK: } // end sil function 'introducer_trivial'
80
107
// CHECK: Introducers:
81
- // CHECK-NEXT: introducer_trivial: find-borrow-introducers with: @trace[0]
108
+ // CHECK-NEXT: introducer_trivial: find-borrow-introducers with: %phi
109
+
110
+ // CHECK-LABEL: introducer_trivial: borrow_introducers with: %phi
111
+ // CHECK: } // end sil function 'introducer_trivial'
112
+ // CHECK: Borrow introducers for: %2 = argument of bb1 : $FakeOptional<C>
113
+ // CHECK-NEXT: introducer_trivial: borrow_introducers with: %phi
82
114
83
115
sil [ossa] @introducer_trivial : $@convention(thin) () -> () {
84
116
entry:
85
117
%trivial = enum $FakeOptional<C>, #FakeOptional.none!enumelt
86
118
br none(%trivial : $FakeOptional<C>)
87
119
88
120
none(%phi : @guaranteed $FakeOptional<C>):
89
- specify_test "find-borrow-introducers @trace[0] "
90
- debug_value [trace] %phi : $FakeOptional<C>
121
+ specify_test "find-borrow-introducers %phi "
122
+ specify_test "borrow_introducers %phi"
91
123
%retval = tuple ()
92
124
return %retval : $()
93
125
}
@@ -97,19 +129,24 @@ none(%phi : @guaranteed $FakeOptional<C>):
97
129
// TODO: When we have a reborrow flag, an unreachable phi can be
98
130
// either a reborrow or forwarded, as long as it has no end_borrow.
99
131
100
- // CHECK-LABEL: introducer_unreachable: find-borrow-introducers with: @trace[0]
132
+ // CHECK-LABEL: introducer_unreachable: find-borrow-introducers with: %phiCycle
101
133
// CHECK: } // end sil function 'introducer_unreachable'
102
134
// CHECK: Introducers:
103
135
// CHECK-NEXT: argument of bb1 : $C
104
- // CHECK-NEXT: introducer_unreachable: find-borrow-introducers with: @trace[0]
136
+ // CHECK-NEXT: introducer_unreachable: find-borrow-introducers with: %phiCycle
105
137
138
+ // CHECK-LABEL: introducer_unreachable: borrow_introducers with: %phiCycle
139
+ // CHECK: } // end sil function 'introducer_unreachable'
140
+ // CHECK: Borrow introducers for: %1 = argument of bb1 : $C
141
+ // CHECK-NEXT: argument of bb1 : $C
142
+ // CHECK-NEXT: introducer_unreachable: borrow_introducers with: %phiCycle
106
143
sil [ossa] @introducer_unreachable : $@convention(thin) () -> () {
107
144
entry:
108
145
br exit
109
146
110
147
unreachable_loop(%phiCycle : @guaranteed $C):
111
- specify_test "find-borrow-introducers @trace[0] "
112
- debug_value [trace] %phiCycle : $C
148
+ specify_test "find-borrow-introducers %phiCycle "
149
+ specify_test "borrow_introducers %phiCycle"
113
150
br unreachable_loop(%phiCycle : $C)
114
151
115
152
exit:
@@ -120,12 +157,17 @@ exit:
120
157
// All data flow paths through phis and aggregates originate from the
121
158
// same function argument.
122
159
123
- // CHECK-LABEL: introducer_single: find-borrow-introducers with: @trace[0]
160
+ // CHECK-LABEL: introducer_single: find-borrow-introducers with: %aggregate2
124
161
// CHECK: } // end sil function 'introducer_single'
125
162
// CHECK: Introducers:
126
163
// CHECK-NEXT: %0 = argument of bb0 : $C
127
- // CHECK-NEXT: introducer_single: find-borrow-introducers with: @trace[0]
164
+ // CHECK-NEXT: introducer_single: find-borrow-introducers with: %aggregate2
128
165
166
+ // CHECK-LABEL: introducer_single: borrow_introducers with: %aggregate2
167
+ // CHECK: } // end sil function 'introducer_single'
168
+ // CHECK: Borrow introducers for: %11 = struct $PairC (%9 : $C, %10 : $C)
169
+ // CHECK-NEXT: %0 = argument of bb0 : $C
170
+ // CHECK-NEXT: introducer_single: borrow_introducers with: %aggregate2
129
171
sil [ossa] @introducer_single : $@convention(thin) (@guaranteed C) -> () {
130
172
entry(%0 : @guaranteed $C):
131
173
%cast = unconditional_checked_cast %0 : $C to D
@@ -141,8 +183,8 @@ bb1(%payload : @guaranteed $D):
141
183
%first = struct_extract %aggregate : $PairC, #PairC.first
142
184
%second = struct_extract %aggregate : $PairC, #PairC.second
143
185
%aggregate2 = struct $PairC(%first : $C, %second : $C)
144
- specify_test "find-borrow-introducers @trace[0] "
145
- debug_value [trace] %aggregate2 : $PairC
186
+ specify_test "find-borrow-introducers %aggregate2 "
187
+ specify_test "borrow_introducers %aggregate2"
146
188
br exit
147
189
148
190
bb2:
@@ -161,14 +203,21 @@ exit:
161
203
// %reborrow. Therefore, %reborrow is an introducer from separate phi
162
204
// paths, but should only appear in the introducer list once.
163
205
//
164
- // CHECK-LABEL: introducer_revisit_reborrow: find-borrow-introducers with: @trace[0]
206
+ // CHECK-LABEL: introducer_revisit_reborrow: find-borrow-introducers with: %aggregate2
165
207
// CHECK: bb1([[REBORROW:%.*]] : @reborrow @guaranteed $C
166
208
// CHECK: } // end sil function 'introducer_revisit_reborrow'
167
209
// CHECK: Introducers:
168
210
// CHECK-NEXT: [[REBORROW]] = argument of bb1 : $C
169
211
// CHECK-NEXT: %0 = argument of bb0 : $C
170
- // CHECK-NEXT: introducer_revisit_reborrow: find-borrow-introducers with: @trace[0]
212
+ // CHECK-NEXT: introducer_revisit_reborrow: find-borrow-introducers with: %aggregate2
171
213
214
+ // CHECK-LABEL: introducer_revisit_reborrow: borrow_introducers with: %aggregate2
215
+ // CHECK: bb1([[REBORROW:%.*]] : @reborrow @guaranteed $C
216
+ // CHECK: } // end sil function 'introducer_revisit_reborrow'
217
+ // CHECK: Borrow introducers for: %{{.*}} = struct $PairC (%{{.*}} : $C, %{{.*}} : $C)
218
+ // CHECK-NEXT: [[REBORROW]] = argument of bb1 : $C
219
+ // CHECK-NEXT: %0 = argument of bb0 : $C
220
+ // CHECK-NEXT: introducer_revisit_reborrow: borrow_introducers with: %aggregate2
172
221
sil [ossa] @introducer_revisit_reborrow : $@convention(thin) (@guaranteed C) -> () {
173
222
entry(%0 : @guaranteed $C):
174
223
%borrow1 = begin_borrow %0 : $C
@@ -178,8 +227,8 @@ entry(%0 : @guaranteed $C):
178
227
bb2(%reborrow : @guaranteed $C, %phi : @guaranteed $PairC):
179
228
%first = struct_extract %phi : $PairC, #PairC.first
180
229
%aggregate2 = struct $PairC(%reborrow : $C, %first : $C)
181
- specify_test "find-borrow-introducers @trace[0] "
182
- debug_value [trace] %aggregate2 : $PairC
230
+ specify_test "find-borrow-introducers %aggregate2 "
231
+ specify_test "borrow_introducers %aggregate2"
183
232
br exit
184
233
185
234
exit:
@@ -191,7 +240,7 @@ exit:
191
240
// %phi originates from %0, %borrow1, & %borrow2. %borrow1 is, however,
192
241
// reborrowed in bb2.
193
242
194
- // CHECK-LABEL: introducer_multiple_borrow: find-borrow-introducers with: @trace[0]
243
+ // CHECK-LABEL: introducer_multiple_borrow: find-borrow-introducers with: %aggregate2
195
244
// CHECK: begin_borrow %0 : $C
196
245
// CHECK: [[BORROW2:%.*]] = begin_borrow %0 : $C
197
246
// CHECK: bb1([[REBORROW:%.*]] : @reborrow @guaranteed $C
@@ -200,8 +249,18 @@ exit:
200
249
// CHECK-NEXT: [[REBORROW]] = argument of bb1 : $C
201
250
// CHECK-NEXT: %0 = argument of bb0 : $C
202
251
// CHECK-NEXT: [[BORROW2]] = begin_borrow %0 : $C
203
- // CHECK-NEXT: introducer_multiple_borrow: find-borrow-introducers with: @trace[0]
252
+ // CHECK-NEXT: introducer_multiple_borrow: find-borrow-introducers with: %aggregate2
204
253
254
+ // CHECK-LABEL: introducer_multiple_borrow: borrow_introducers with: %aggregate2
255
+ // CHECK: begin_borrow %0 : $C
256
+ // CHECK: [[BORROW2:%.*]] = begin_borrow %0 : $C
257
+ // CHECK: bb1([[REBORROW:%.*]] : @reborrow @guaranteed $C
258
+ // CHECK: } // end sil function 'introducer_multiple_borrow'
259
+ // CHECK: Borrow introducers for: %{{.*}} = struct $PairC (%{{.*}} : $C, %{{.*}} : $C)
260
+ // CHECK-NEXT: [[REBORROW]] = argument of bb1 : $C
261
+ // CHECK-NEXT: %0 = argument of bb0 : $C
262
+ // CHECK-NEXT: [[BORROW2]] = begin_borrow %0 : $C
263
+ // CHECK-NEXT: introducer_multiple_borrow: borrow_introducers with: %aggregate2
205
264
sil [ossa] @introducer_multiple_borrow : $@convention(thin) (@guaranteed C) -> () {
206
265
entry(%0 : @guaranteed $C):
207
266
%borrow1 = begin_borrow %0 : $C
@@ -212,8 +271,8 @@ entry(%0 : @guaranteed $C):
212
271
bb2(%reborrow : @guaranteed $C, %phi : @guaranteed $PairC):
213
272
%first = struct_extract %phi : $PairC, #PairC.first
214
273
%aggregate2 = struct $PairC(%reborrow : $C, %first : $C)
215
- specify_test "find-borrow-introducers @trace[0] "
216
- debug_value [trace] %aggregate2 : $PairC
274
+ specify_test "find-borrow-introducers %aggregate2 "
275
+ specify_test "borrow_introducers %aggregate2"
217
276
br exit
218
277
219
278
exit:
@@ -223,28 +282,102 @@ exit:
223
282
return %retval : $()
224
283
}
225
284
226
- // CHECK-LABEL: begin running test 1 of 1 on introducer_dependence: find-borrow-introducers with: @trace[0]
285
+ // CHECK-LABEL: introducer_dependence: find-borrow-introducers with: %dependent
227
286
// CHECK: Introducers:
228
287
// CHECK: %0 = argument of bb0 : $C
229
- // CHECK-LABEL: end running test 1 of 1 on introducer_dependence: find-borrow-introducers with: @trace[0]
288
+ // CHECK-LABEL: introducer_dependence: find-borrow-introducers with: %dependent
289
+
290
+ // CHECK-LABEL: introducer_dependence: borrow_introducers with: %dependent
291
+ // CHECK: Borrow introducers for: %{{.*}} = mark_dependence %0 : $C on %1 : $Builtin.NativeObject
292
+ // CHECK: %0 = argument of bb0 : $C
293
+ // CHECK-NEXT: introducer_dependence: borrow_introducers with: %dependent
230
294
sil [ossa] @introducer_dependence : $@convention(thin) (@guaranteed C, @guaranteed Builtin.NativeObject) -> () {
231
295
entry(%0 : @guaranteed $C, %1 : @guaranteed $Builtin.NativeObject):
232
- specify_test "find-borrow-introducers @trace[0]"
296
+ specify_test "find-borrow-introducers %dependent"
297
+ specify_test "borrow_introducers %dependent"
233
298
%dependent = mark_dependence %0 : $C on %1 : $Builtin.NativeObject
234
- debug_value [trace] %dependent : $C
235
299
%retval = tuple ()
236
300
return %retval : $()
237
301
}
238
302
239
- // CHECK-LABEL: begin running test 1 of 1 on introducer_bridge: find-borrow-introducers with: @trace[0]
303
+ // CHECK-LABEL: introducer_bridge: find-borrow-introducers with: %bridge
240
304
// CHECK: Introducers:
241
305
// CHECK: %0 = argument of bb0 : $C
242
- // CHECK-LABEL: end running test 1 of 1 on introducer_bridge: find-borrow-introducers with: @trace[0]
306
+ // CHECK-LABEL: introducer_bridge: find-borrow-introducers with: %bridge
307
+
308
+ // CHECK-LABEL: introducer_bridge: borrow_introducers with: %bridge
309
+ // CHECK: Borrow introducers for: %{{.*}} = ref_to_bridge_object %0 : $C, %1 : $Builtin.Word
310
+ // CHECK: %0 = argument of bb0 : $C
311
+ // CHECK-NEXT: introducer_bridge: borrow_introducers with: %bridge
243
312
sil [ossa] @introducer_bridge : $@convention(thin) (@guaranteed C, Builtin.Word) -> () {
244
313
entry(%0 : @guaranteed $C, %1 : $Builtin.Word):
245
- specify_test "find-borrow-introducers @trace[0]"
314
+ specify_test "find-borrow-introducers %bridge"
315
+ specify_test "borrow_introducers %bridge"
246
316
%bridge = ref_to_bridge_object %0 : $C, %1 : $Builtin.Word
247
- debug_value [trace] %bridge : $Builtin.BridgeObject
317
+ %retval = tuple ()
318
+ return %retval : $()
319
+ }
320
+
321
+ // CHECK-LABEL: introducer_begin_apply: borrow_introducers with: %bridge
322
+ // CHECK: Borrow introducers for: %{{.*}} = ref_to_bridge_object %{{.*}} : $C, %0 : $Builtin.Word
323
+ // CHECK-NEXT: (**%{{.*}}**, %{{.*}}) = begin_apply %{{.*}}() : $@yield_once @convention(thin) () -> @yields @guaranteed C
324
+ // CHECK-NEXT: introducer_begin_apply: borrow_introducers with: %bridge
325
+ sil [ossa] @introducer_begin_apply : $@convention(thin) (Builtin.Word) -> () {
326
+ bb0(%0 : $Builtin.Word):
327
+ %f = function_ref @coro : $@yield_once @convention(thin) () -> @yields @guaranteed C
328
+ (%c, %t) = begin_apply %f() : $@yield_once @convention(thin) () -> @yields @guaranteed C
329
+ specify_test "borrow_introducers %bridge"
330
+ %bridge = ref_to_bridge_object %c : $C, %0 : $Builtin.Word
331
+ cond_br undef, bb1, bb2
332
+ bb1:
333
+ end_apply %t
334
+ %r = tuple ()
335
+ return %r : $()
336
+ bb2:
337
+ abort_apply %t
338
+ unreachable
339
+ }
340
+
341
+ // CHECK-LABEL: introducer_example: borrow_introducers with: %0
342
+ // CHECK: Borrow introducers for: %0 = argument of bb0 : $C
343
+ // CHECK-NEXT: %0 = argument of bb0 : $C
344
+ // CHECK-NEXT: introducer_example: borrow_introducers with: %0
345
+
346
+ // CHECK-LABEL: introducer_example: borrow_introducers with: %borrow0
347
+ // CHECK: Borrow introducers for: %{{.*}} = begin_borrow %0 : $C
348
+ // CHECK-NEXT: %{{.*}} = begin_borrow %0 : $C
349
+ // CHECK-NEXT: introducer_example: borrow_introducers with: %borrow0
350
+
351
+ // CHECK-LABEL: introducer_example: borrow_introducers with: %first
352
+ // CHECK: Borrow introducers for: %{{.*}} = struct_extract %{{.*}} : $PairC, #PairC.first
353
+ // CHECK-NEXT: %{{.*}} = begin_borrow %0 : $C
354
+ // CHECK-NEXT: %{{.*}} = argument of bb0 : $C
355
+ // CHECK-NEXT: introducer_example: borrow_introducers with: %first
356
+
357
+ // CHECK-LABEL: introducer_example: borrow_introducers with: %field
358
+ // CHECK: Borrow introducers for: %{{.*}} = ref_element_addr %{{.*}} : $C, #C.field
359
+ // CHECK-NEXT: introducer_example: borrow_introducers with: %field
360
+
361
+ // CHECK-LABEL: introducer_example: borrow_introducers with: %load
362
+ // CHECK-LABEL: Borrow introducers for: %{{.*}} = load_borrow %{{.*}} : $*C
363
+ // CHECK-NEXT: %{{.*}} = load_borrow %{{.*}} : $*C
364
+ // CHECK-NEXT: introducer_example: borrow_introducers with: %
365
+ sil [ossa] @introducer_example : $@convention(thin) (@owned C, @guaranteed C) -> () {
366
+ bb0(%0 : @owned $C,
367
+ %1 : @guaranteed $C):
368
+ specify_test "borrow_introducers %0"
369
+ %borrow0 = begin_borrow %0 : $C
370
+ specify_test "borrow_introducers %borrow0"
371
+ %pair = struct $PairC(%borrow0 : $C, %1 : $C)
372
+ %first = struct_extract %pair : $PairC, #PairC.first
373
+ specify_test "borrow_introducers %first"
374
+ %field = ref_element_addr %first : $C, #C.field
375
+ specify_test "borrow_introducers %field"
376
+ %load = load_borrow %field : $*C
377
+ specify_test "borrow_introducers %load"
378
+ end_borrow %load : $C
379
+ end_borrow %borrow0 : $C
380
+ destroy_value %0 : $C
248
381
%retval = tuple ()
249
382
return %retval : $()
250
383
}
0 commit comments