@@ -20,36 +20,126 @@ struct S {
20
20
@_hasStorage var b: Int64
21
21
}
22
22
23
+ sil @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
24
+ sil @unknown_addr : $@convention(thin) (@in Int64) -> ()
25
+
23
26
// CHECK-LABEL: sil [stack_protection] @function_local_stack
24
27
// CHECK-NOT: copy_addr
25
28
// CHECK: } // end sil function 'function_local_stack'
26
- sil @function_local_stack : $@convention(thin) () -> () {
29
+ sil @function_local_stack : $@convention(thin) (Int64) -> () {
30
+ bb0(%0 : $Int64):
31
+ %1 = alloc_stack $Int64
32
+ %2 = address_to_pointer [stack_protection] %1 : $*Int64 to $Builtin.RawPointer
33
+ %3 = pointer_to_address %2 : $Builtin.RawPointer to $*Int64
34
+ store %0 to %3 : $*Int64
35
+ dealloc_stack %1 : $*Int64
36
+ %r = tuple ()
37
+ return %r : $()
38
+ }
39
+
40
+ // CHECK-LABEL: sil @only_loads
41
+ // CHECK-NOT: copy_addr
42
+ // CHECK: } // end sil function 'only_loads'
43
+ sil @only_loads : $@convention(thin) () -> Int64 {
44
+ bb0:
45
+ %1 = alloc_stack $Int64
46
+ %2 = address_to_pointer [stack_protection] %1 : $*Int64 to $Builtin.RawPointer
47
+ %3 = pointer_to_address %2 : $Builtin.RawPointer to $*Int64
48
+ %4 = load %3 : $*Int64
49
+ dealloc_stack %1 : $*Int64
50
+ return %4 : $Int64
51
+ }
52
+
53
+ // CHECK-LABEL: sil @copy_addr_src
54
+ // CHECK: } // end sil function 'copy_addr_src'
55
+ sil @copy_addr_src : $@convention(thin) () -> @out Int64 {
56
+ bb0(%0 : $*Int64):
57
+ %1 = alloc_stack $Int64
58
+ %2 = address_to_pointer [stack_protection] %1 : $*Int64 to $Builtin.RawPointer
59
+ %3 = pointer_to_address %2 : $Builtin.RawPointer to $*Int64
60
+ copy_addr %3 to %0 : $*Int64
61
+ dealloc_stack %1 : $*Int64
62
+ %r = tuple ()
63
+ return %r : $()
64
+ }
65
+
66
+ // CHECK-LABEL: sil [stack_protection] @copy_addr_dst
67
+ // CHECK: } // end sil function 'copy_addr_dst'
68
+ sil @copy_addr_dst : $@convention(thin) (@in Int64) -> () {
69
+ bb0(%0 : $*Int64):
70
+ %1 = alloc_stack $Int64
71
+ %2 = address_to_pointer [stack_protection] %1 : $*Int64 to $Builtin.RawPointer
72
+ %3 = pointer_to_address %2 : $Builtin.RawPointer to $*Int64
73
+ copy_addr %0 to %3 : $*Int64
74
+ dealloc_stack %1 : $*Int64
75
+ %r = tuple ()
76
+ return %r : $()
77
+ }
78
+
79
+ // CHECK-LABEL: sil [stack_protection] @escaping_pointer
80
+ // CHECK-NOT: copy_addr
81
+ // CHECK: } // end sil function 'escaping_pointer'
82
+ sil @escaping_pointer : $@convention(thin) () -> () {
83
+ bb0:
84
+ %1 = alloc_stack $Int64
85
+ %2 = address_to_pointer [stack_protection] %1 : $*Int64 to $Builtin.RawPointer
86
+ %3 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
87
+ apply %3(%2) : $@convention(thin) (Builtin.RawPointer) -> ()
88
+ dealloc_stack %1 : $*Int64
89
+ %r = tuple ()
90
+ return %r : $()
91
+ }
92
+
93
+ // CHECK-LABEL: sil @no_stack_protection_for_index_addr
94
+ // CHECK-NOT: copy_addr
95
+ // CHECK: } // end sil function 'no_stack_protection_for_index_addr'
96
+ sil @no_stack_protection_for_index_addr : $@convention(thin) () -> () {
27
97
bb0:
28
98
%0 = alloc_stack $Int64
29
- %1 = address_to_pointer [stack_protection] %0 : $*Int64 to $Builtin.RawPointer
99
+ %1 = address_to_pointer %0 : $*Int64 to $Builtin.RawPointer
100
+ %2 = integer_literal $Builtin.Word, 1
101
+ %3 = index_addr %0 : $*Int64, %2 : $Builtin.Word
102
+ %4 = function_ref @unknown_addr : $@convention(thin) (@in Int64) -> ()
103
+ apply %4(%3) : $@convention(thin) (@in Int64) -> ()
30
104
dealloc_stack %0 : $*Int64
31
105
%r = tuple ()
32
106
return %r : $()
33
107
}
34
108
35
- // CHECK-LABEL: sil @no_stack_protection
109
+ // CHECK-LABEL: sil [stack_protection] @stack_protection_for_index_addr
36
110
// CHECK-NOT: copy_addr
37
- // CHECK: } // end sil function 'no_stack_protection '
38
- sil @no_stack_protection : $@convention(thin) () -> () {
111
+ // CHECK: } // end sil function 'stack_protection_for_index_addr '
112
+ sil @stack_protection_for_index_addr : $@convention(thin) () -> () {
39
113
bb0:
40
114
%0 = alloc_stack $Int64
41
115
%1 = address_to_pointer %0 : $*Int64 to $Builtin.RawPointer
42
116
%2 = integer_literal $Builtin.Word, 1
43
- %3 = index_addr %0 : $*Int64, %2 : $Builtin.Word
117
+ %3 = index_addr [stack_protection] %0 : $*Int64, %2 : $Builtin.Word
118
+ %4 = function_ref @unknown_addr : $@convention(thin) (@in Int64) -> ()
119
+ apply %4(%3) : $@convention(thin) (@in Int64) -> ()
44
120
dealloc_stack %0 : $*Int64
45
121
%r = tuple ()
46
122
return %r : $()
47
123
}
48
124
49
- // CHECK-LABEL: sil [stack_protection] @stack_alloc_builtin
125
+ // CHECK-LABEL: sil @index_addr_with_only_loads
50
126
// CHECK-NOT: copy_addr
51
- // CHECK: } // end sil function 'stack_alloc_builtin'
52
- sil @stack_alloc_builtin : $@convention(thin) () -> () {
127
+ // CHECK: } // end sil function 'index_addr_with_only_loads'
128
+ sil @index_addr_with_only_loads : $@convention(thin) () -> Int64 {
129
+ bb0:
130
+ %0 = alloc_stack $Int64
131
+ %1 = address_to_pointer %0 : $*Int64 to $Builtin.RawPointer
132
+ %2 = integer_literal $Builtin.Word, 1
133
+ %3 = index_addr [stack_protection] %0 : $*Int64, %2 : $Builtin.Word
134
+ %4 = load %3 : $*Int64
135
+ dealloc_stack %0 : $*Int64
136
+ return %4 : $Int64
137
+ }
138
+
139
+ // CHECK-LABEL: sil [stack_protection] @stack_alloc_builtin_with_3_args
140
+ // CHECK-NOT: copy_addr
141
+ // CHECK: } // end sil function 'stack_alloc_builtin_with_3_args'
142
+ sil @stack_alloc_builtin_with_3_args : $@convention(thin) () -> () {
53
143
bb0:
54
144
%0 = integer_literal $Builtin.Word, 8
55
145
%1 = builtin "stackAlloc"(%0 : $Builtin.Word, %0 : $Builtin.Word, %0 : $Builtin.Word) : $Builtin.RawPointer
66
156
%1 = ref_element_addr %0 : $C, #C.i
67
157
%2 = begin_access [modify] [static] %1 : $*Int64
68
158
%3 = address_to_pointer [stack_protection] %2 : $*Int64 to $Builtin.RawPointer
159
+ %4 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
160
+ apply %4(%3) : $@convention(thin) (Builtin.RawPointer) -> ()
69
161
end_access %2 : $*Int64
70
162
dealloc_stack_ref %0 : $C
71
163
%r = tuple ()
81
173
%1 = ref_element_addr %0 : $C, #C.i
82
174
%2 = begin_access [modify] [static] %1 : $*Int64
83
175
%3 = address_to_pointer [stack_protection] %2 : $*Int64 to $Builtin.RawPointer
176
+ %4 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
177
+ apply %4(%3) : $@convention(thin) (Builtin.RawPointer) -> ()
84
178
end_access %2 : $*Int64
85
179
strong_release %0 : $C
86
180
%r = tuple ()
101
195
sil @inout_with_unknown_callers1 : $@convention(thin) (@inout Int64) -> () {
102
196
bb0(%0 : $*Int64):
103
197
%1 = address_to_pointer [stack_protection] %0 : $*Int64 to $Builtin.RawPointer
198
+ %2 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
199
+ apply %2(%1) : $@convention(thin) (Builtin.RawPointer) -> ()
104
200
%r = tuple ()
105
201
return %r : $()
106
202
}
@@ -112,6 +208,8 @@ bb0(%0 : $*Int64):
112
208
sil @in_with_unknown_callers : $@convention(thin) (@in_guaranteed Int64) -> () {
113
209
bb0(%0 : $*Int64):
114
210
%1 = address_to_pointer [stack_protection] %0 : $*Int64 to $Builtin.RawPointer
211
+ %2 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
212
+ apply %2(%1) : $@convention(thin) (Builtin.RawPointer) -> ()
115
213
%r = tuple ()
116
214
return %r : $()
117
215
}
@@ -132,6 +230,8 @@ sil @inout_with_modify_access : $@convention(thin) (@inout Int64) -> () {
132
230
bb0(%0 : $*Int64):
133
231
%1 = begin_access [modify] [dynamic] %0 : $*Int64
134
232
%2 = address_to_pointer [stack_protection] %1 : $*Int64 to $Builtin.RawPointer
233
+ %3 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
234
+ apply %3(%2) : $@convention(thin) (Builtin.RawPointer) -> ()
135
235
end_access %1 : $*Int64
136
236
%r = tuple ()
137
237
return %r : $()
@@ -146,6 +246,8 @@ sil @inout_with_read_access : $@convention(thin) (@inout Int64) -> () {
146
246
bb0(%0 : $*Int64):
147
247
%1 = begin_access [read] [dynamic] %0 : $*Int64
148
248
%2 = address_to_pointer [stack_protection] %1 : $*Int64 to $Builtin.RawPointer
249
+ %3 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
250
+ apply %3(%2) : $@convention(thin) (Builtin.RawPointer) -> ()
149
251
end_access %1 : $*Int64
150
252
%r = tuple ()
151
253
return %r : $()
@@ -168,8 +270,11 @@ sil @inout_with_unknown_callers2 : $@convention(thin) (@inout S) -> () {
168
270
bb0(%0 : $*S):
169
271
%1 = struct_element_addr %0 : $*S, #S.a
170
272
%2 = address_to_pointer [stack_protection] %1 : $*Int64 to $Builtin.RawPointer
171
- %3 = struct_element_addr %0 : $*S, #S.b
172
- %4 = address_to_pointer [stack_protection] %3 : $*Int64 to $Builtin.RawPointer
273
+ %3 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
274
+ apply %3(%2) : $@convention(thin) (Builtin.RawPointer) -> ()
275
+ %5 = struct_element_addr %0 : $*S, #S.b
276
+ %6 = address_to_pointer [stack_protection] %5 : $*Int64 to $Builtin.RawPointer
277
+ apply %3(%6) : $@convention(thin) (Builtin.RawPointer) -> ()
173
278
%r = tuple ()
174
279
return %r : $()
175
280
}
@@ -192,6 +297,8 @@ bb0(%0 : $C):
192
297
%1 = ref_element_addr %0 : $C, #C.i
193
298
%2 = begin_access [modify] [static] %1 : $*Int64
194
299
%3 = address_to_pointer [stack_protection] %2 : $*Int64 to $Builtin.RawPointer
300
+ %4 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
301
+ apply %4(%3) : $@convention(thin) (Builtin.RawPointer) -> ()
195
302
end_access %2 : $*Int64
196
303
%r = tuple ()
197
304
return %r : $()
@@ -216,7 +323,10 @@ bb0(%0 : $C):
216
323
%1 = ref_element_addr %0 : $C, #C.i
217
324
%2 = begin_access [modify] [static] %1 : $*Int64
218
325
%3 = address_to_pointer [stack_protection] %2 : $*Int64 to $Builtin.RawPointer
219
- %4 = address_to_pointer [stack_protection] %2 : $*Int64 to $Builtin.RawPointer
326
+ %4 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
327
+ apply %4(%3) : $@convention(thin) (Builtin.RawPointer) -> ()
328
+ %6 = address_to_pointer [stack_protection] %2 : $*Int64 to $Builtin.RawPointer
329
+ apply %4(%6) : $@convention(thin) (Builtin.RawPointer) -> ()
220
330
end_access %2 : $*Int64
221
331
%r = tuple ()
222
332
return %r : $()
@@ -249,11 +359,14 @@ bb0(%0 : $C):
249
359
// Accesses don't need to be properly nested.
250
360
%2 = begin_access [modify] [static] %1 : $*Int64
251
361
%3 = address_to_pointer [stack_protection] %2 : $*Int64 to $Builtin.RawPointer
252
- %4 = ref_element_addr %0 : $C, #C.j
253
- %5 = begin_access [modify] [static] %4 : $*Int64
362
+ %4 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
363
+ apply %4(%3) : $@convention(thin) (Builtin.RawPointer) -> ()
364
+ %6 = ref_element_addr %0 : $C, #C.j
365
+ %7 = begin_access [modify] [static] %6 : $*Int64
254
366
end_access %2 : $*Int64
255
- %7 = address_to_pointer [stack_protection] %5 : $*Int64 to $Builtin.RawPointer
256
- end_access %5 : $*Int64
367
+ %9 = address_to_pointer [stack_protection] %7 : $*Int64 to $Builtin.RawPointer
368
+ apply %4(%9) : $@convention(thin) (Builtin.RawPointer) -> ()
369
+ end_access %7 : $*Int64
257
370
%r = tuple ()
258
371
return %r : $()
259
372
}
@@ -270,6 +383,8 @@ bb0(%0 : $C):
270
383
%1 = ref_element_addr %0 : $C, #C.i
271
384
%2 = begin_access [read] [static] %1 : $*Int64
272
385
%3 = address_to_pointer [stack_protection] %2 : $*Int64 to $Builtin.RawPointer
386
+ %4 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
387
+ apply %4(%3) : $@convention(thin) (Builtin.RawPointer) -> ()
273
388
end_access %2 : $*Int64
274
389
%r = tuple ()
275
390
return %r : $()
@@ -368,8 +483,10 @@ bb0(%0 : $*Int64):
368
483
sil @partially_known_callers : $@convention(thin) (@inout Int64) -> () {
369
484
bb0(%0 : $*Int64):
370
485
%1 = address_to_pointer [stack_protection] %0 : $*Int64 to $Builtin.RawPointer
371
- %2 = tuple ()
372
- return %2 : $()
486
+ %2 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
487
+ apply %2(%1) : $@convention(thin) (Builtin.RawPointer) -> ()
488
+ %4 = tuple ()
489
+ return %4 : $()
373
490
}
374
491
375
492
// MOVE-LABEL: sil @call_partially_known_callers
@@ -394,6 +511,8 @@ bb0(%0 : $C):
394
511
%1 = ref_element_addr %0 : $C, #C.i
395
512
%2 = begin_access [modify] [static] %1 : $*Int64
396
513
%3 = address_to_pointer [stack_protection] %2 : $*Int64 to $Builtin.RawPointer
514
+ %4 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
515
+ apply %4(%3) : $@convention(thin) (Builtin.RawPointer) -> ()
397
516
end_access %2 : $*Int64
398
517
%7 = tuple ()
399
518
return %7 : $()
@@ -445,6 +564,8 @@ bb0(%0 : $C):
445
564
%1 = ref_element_addr %0 : $C, #C.i
446
565
%2 = begin_access [modify] [static] %1 : $*Int64
447
566
%3 = address_to_pointer [stack_protection] %2 : $*Int64 to $Builtin.RawPointer
567
+ %4 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
568
+ apply %4(%3) : $@convention(thin) (Builtin.RawPointer) -> ()
448
569
end_access %2 : $*Int64
449
570
%7 = tuple ()
450
571
return %7 : $()
@@ -479,6 +600,8 @@ bb3(%5 : $C):
479
600
sil private @closure_with_inout_capture : $@convention(thin) (@inout_aliasable Int64) -> () {
480
601
bb0(%0 : $*Int64):
481
602
%1 = address_to_pointer [stack_protection] %0 : $*Int64 to $Builtin.RawPointer
603
+ %2 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
604
+ apply %2(%1) : $@convention(thin) (Builtin.RawPointer) -> ()
482
605
%r = tuple ()
483
606
return %r : $()
484
607
}
517
640
sil private @closure_with_inout_arg : $@convention(thin) (@inout Int64) -> () {
518
641
bb0(%0 : $*Int64):
519
642
%1 = address_to_pointer [stack_protection] %0 : $*Int64 to $Builtin.RawPointer
643
+ %2 = function_ref @unknown : $@convention(thin) (Builtin.RawPointer) -> ()
644
+ apply %2(%1) : $@convention(thin) (Builtin.RawPointer) -> ()
520
645
%r = tuple ()
521
646
return %r : $()
522
647
}
0 commit comments