@@ -125,17 +125,13 @@ sil @S7_init : $@convention(thin) (@thin S7.Type) -> S7
125
125
sil @S8_init : $@convention(thin) (@thin S8.Type) -> @owned S8
126
126
sil @escaped_a : $@convention(thin) () -> Builtin.RawPointer
127
127
128
- //////////////////////////////////////////////////////////////
129
- // Tests for LoadStoreOpts.cpp from globalloadstoreopts.sil //
130
- //////////////////////////////////////////////////////////////
131
-
132
128
// We should be able to remove the local store that is not read.
133
129
//
134
- // CHECK-LABEL: DeadLocalStoreSimpleStruct
130
+ // CHECK-LABEL: trivial_local_dead_store
135
131
// CHECK: bb0
136
132
// CHECK-NOT: store
137
133
// CHECK: return
138
- sil hidden @DeadLocalStoreSimpleStruct : $@convention(thin) () -> () {
134
+ sil hidden @trivial_local_dead_store : $@convention(thin) () -> () {
139
135
bb0:
140
136
%0 = alloc_stack $Int, var, name "a" // users: %3, %5
141
137
%1 = integer_literal $Builtin.Int64, 1 // user: %2
@@ -148,11 +144,11 @@ bb0:
148
144
149
145
// We can not remove the local store that is read.
150
146
//
151
- // CHECK-LABEL: NoDeadLocalStoreSimpleStruct
147
+ // CHECK-LABEL: blocking_read_on_local_store
152
148
// CHECK: bb0
153
149
// CHECK: store
154
150
// CHECK: return
155
- sil hidden @NoDeadLocalStoreSimpleStruct : $@convention(thin) () -> () {
151
+ sil hidden @blocking_read_on_local_store : $@convention(thin) () -> () {
156
152
bb0:
157
153
%0 = alloc_stack $Int, var, name "a" // users: %3, %5
158
154
%1 = integer_literal $Builtin.Int64, 1 // user: %2
@@ -164,34 +160,10 @@ bb0:
164
160
return %4 : $() // id: %6
165
161
}
166
162
167
- // TEST CASE CURRENTLY DISABLED.
168
- // There is currently a outstand radar in the swift type/aa system, will
169
- // take this flag off once thats fixed.
170
- //
171
- // We can not remove the local store as the debug_value_addr could
172
- // be turned to a debug_value and thus act as a read on the memory
173
- // location..
174
- //
175
- // DISABLECHECK-LABEL: NoDeadStoreDebugValueAddr
176
- // DISABLECHECK: bb0
177
- // DISABLECHECK: store
178
- // DISABLECHECK: debug_value_addr
179
- sil hidden @NoDeadStoreDebugValueAddr : $@convention(thin) () -> () {
180
- bb0:
181
- %0 = alloc_stack $Int, var, name "a" // users: %3, %5
182
- %1 = integer_literal $Builtin.Int64, 1 // user: %2
183
- %2 = struct $Int (%1 : $Builtin.Int64) // user: %3
184
- store %2 to %0#1 : $*Int // id: %3
185
- debug_value_addr %0#1 : $*Int
186
- %4 = tuple () // user: %6
187
- dealloc_stack %0#0 : $*@local_storage Int // id: %5
188
- return %4 : $() // id: %6
189
- }
190
-
191
163
// CHECK-LABEL: sil @store_after_store
192
164
// CHECK: alloc_box
193
- // CHECK-NEXT : store
194
- // CHECK-NEXT: tuple
165
+ // CHECK: store
166
+ // CHECK-NOT: store
195
167
// CHECK: return
196
168
sil @store_after_store : $@convention(thin) (@owned B) -> () {
197
169
bb0(%0 : $B):
@@ -299,6 +271,26 @@ bb2:
299
271
return %9999 : $()
300
272
}
301
273
274
+ // We can not remove the local store as the debug_value_addr could
275
+ // be turned to a debug_value and thus act as a read on the memory
276
+ // location..
277
+ //
278
+ // CHECK-LABEL: blocking_debug_value_addr_on_dead_store
279
+ // CHECK: bb0
280
+ // CHECK: store
281
+ // CHECK: debug_value_addr
282
+ sil hidden @blocking_debug_value_addr_on_dead_store : $@convention(thin) () -> () {
283
+ bb0:
284
+ %0 = alloc_stack $Int, var, name "a" // users: %3, %5
285
+ %1 = integer_literal $Builtin.Int64, 1 // user: %2
286
+ %2 = struct $Int (%1 : $Builtin.Int64) // user: %3
287
+ store %2 to %0#1 : $*Int // id: %3
288
+ debug_value_addr %0#1 : $*Int
289
+ %4 = tuple () // user: %6
290
+ dealloc_stack %0#0 : $*@local_storage Int // id: %5
291
+ return %4 : $() // id: %6
292
+ }
293
+
302
294
// CHECK-LABEL: sil @test_read_dependence_allows_forwarding : $@convention(thin) (@inout A, A) -> A {
303
295
// CHECK: bb0
304
296
// CHECK-NEXT: store
@@ -382,25 +374,14 @@ bb3:
382
374
return %9999 : $()
383
375
}
384
376
385
- //////////////////////////////////////////////
386
- // Tests for GlobalDeadStoreElimination.cpp //
387
- //////////////////////////////////////////////
388
-
389
377
// We should be able to remove the store in bb0, but we currently
390
378
// cant due to deficiency in alias analysis.
391
379
//
392
380
// CHECK-LABEL: DeadStoreWithAliasingBasesSimpleClass
393
381
// CHECK: bb0([[RET0:%.+]] : $Bool):
394
- // CHECK-NEXT: [[RET1:%.+]] = alloc_ref
395
- // CHECK-NEXT: [[RET2:%.+]] = alloc_stack
396
- // CHECK-NEXT: store [[RET1:%.+]] to [[RET2:%.+]]
397
- // CHECK-NEXT: [[RET2:%.+]] = load
398
- // CHECK-NEXT: [[RET3:%.+]] = integer_literal
399
- // CHECK-NEXT: [[RET4:%.+]] = struct $Int
400
- // CHECK-NEXT: [[RET5:%.+]] = ref_element_addr
401
- // CHECK-NEXT: store [[RET4:%.+]] to [[RET5:%.+]]
402
- // CHECK-NEXT: [[RET6:%.+]] = ref_element_addr
403
- // CHECK-NEXT: store [[RET4:%.+]] to [[RET6:%.+]]
382
+ // CHECK: store
383
+ // CHECK: store
384
+ // CHECK: store
404
385
sil hidden @DeadStoreWithAliasingBasesSimpleClass : $@convention(thin) (Bool) -> () {
405
386
bb0(%0 : $Bool):
406
387
%1 = alloc_ref $foo // users: %3, %6
@@ -413,9 +394,6 @@ bb0(%0 : $Bool):
413
394
store %5 to %6 : $*Int // id: %7
414
395
%9 = ref_element_addr %8 : $foo, #foo.a // user: %12
415
396
store %5 to %9 : $*Int // id: %12
416
- br bb1 // id: %13
417
-
418
- bb1: // Preds: bb0
419
397
%14 = tuple () // user: %16
420
398
dealloc_stack %2#0 : $*@local_storage foo // id: %15
421
399
return %14 : $() // id: %16
@@ -424,14 +402,14 @@ bb1: // Preds: bb0
424
402
// Remove dead stores in if-else block on a simple struct as there are stores
425
403
// in the joint block.
426
404
//
427
- // CHECK-LABEL: DeadStoreInIfElseBlockSimpleStruct
405
+ // CHECK-LABEL: diamond_control_flow_dead_store
428
406
// CHECK: bb1:
429
407
// CHECK-NOT: store
430
408
// CHECK: br
431
409
// CHECK: bb2:
432
410
// CHECK-NOT: store
433
411
// CHECK: br
434
- sil hidden @DeadStoreInIfElseBlockSimpleStruct : $@convention(thin) (Bool, Int) -> () {
412
+ sil hidden @diamond_control_flow_dead_store : $@convention(thin) (Bool, Int) -> () {
435
413
bb0(%0 : $Bool, %1 : $Int):
436
414
%2 = alloc_stack $S1 // users: %6, %11, %16, %21, %24
437
415
// function_ref S1_init
@@ -965,13 +943,11 @@ bb4: // Preds: bb2 bb3
965
943
966
944
// Can not remove partially dead store in split block for simple class.
967
945
//
968
- // CHECK-LABEL: PartialDeadStoreInSplitSimpleClass
946
+ // CHECK-LABEL: partial_dead_store_simple_class
969
947
// CHECK: bb1:
970
- // CHECK-NEXT: [[RET0:%.+]] = integer_literal $Builtin.Int64, 10
971
- // CHECK-NEXT: [[RET1:%.+]] = struct $Int ([[RET0:%.+]] : $Builtin.Int64)
972
- // CHECK-NEXT: [[RET2:%.+]] = ref_element_addr
973
- // CHECK-NEXT: store [[RET1:%.+]] to [[RET2:%.+]]
974
- sil hidden @PartialDeadStoreInSplitSimpleClass : $@convention(thin) (Bool) -> () {
948
+ // CHECK: store
949
+ // CHECK: cond_br
950
+ sil hidden @partial_dead_store_simple_class : $@convention(thin) (Bool) -> () {
975
951
bb0(%0 : $Bool):
976
952
%1 = alloc_stack $foo // users: %3, %20
977
953
%2 = alloc_ref $foo // users: %3, %7, %14, %18
@@ -1006,13 +982,11 @@ bb4: // Preds: bb2 bb3
1006
982
1007
983
// Can not remove partially dead store in split block for simple class.
1008
984
//
1009
- // CHECK-LABEL: PartialDeadStoreInSplitWithFunctionCallSimpleClass
985
+ // CHECK-LABEL: partial_dead_store_with_function_call
1010
986
// CHECK: bb1:
1011
- // CHECK-NEXT: [[RET0:%.+]] = integer_literal $Builtin.Int64, 10
1012
- // CHECK-NEXT: [[RET1:%.+]] = struct $Int ([[RET0:%.+]] : $Builtin.Int64)
1013
- // CHECK-NEXT: [[RET2:%.+]] = ref_element_addr
1014
- // CHECK-NEXT: store [[RET1:%.+]] to [[RET2:%.+]]
1015
- sil hidden @PartialDeadStoreInSplitWithFunctionCallSimpleClass : $@convention(thin) (Bool) -> () {
987
+ // CHECK: store
988
+ // CHECK: cond_br
989
+ sil hidden @partial_dead_store_with_function_call : $@convention(thin) (Bool) -> () {
1016
990
bb0(%0 : $Bool):
1017
991
%1 = alloc_stack $foo // users: %8, %36
1018
992
%3 = alloc_ref $foo // users: %6, %8, %11, %14, %17, %19, %22, %25, %27, %30, %33, %34
0 commit comments