Skip to content

Commit 9f46eb5

Browse files
authored
Merge pull request #4186 from trentxintong/RL
Clean up a SIL test file for redundant load elimination
2 parents 52f16f0 + cb83338 commit 9f46eb5

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

test/SILOptimizer/globalredundantloadelimination.sil renamed to test/SILOptimizer/redundant_load_elim_with_casts.sil

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
// RUN: %target-sil-opt -enable-sil-verify-all %s -module-name Swift -redundant-load-elim
2-
// FIXME: This test is not FileCheck'd
1+
// RUN: %target-sil-opt -enable-sil-verify-all %s -module-name Swift -redundant-load-elim | FileCheck -check-prefix=CHECK-FUTURE %s
2+
//
3+
// FIXME: Contains tests which are handled by old RLE, but not current one. Mostly due to casting. Eventually we probably should
4+
// handle these cases if they turn out to be important.
5+
//
6+
// The problem is the current RLE uses type projection tree/path to model fields in an object. This makes it difficult for it to
7+
// reason about casts, i.e. 1 memory with different types.
8+
//
9+
// Tracked by rdar://23023366
310

411
import Builtin
512

@@ -59,7 +66,7 @@ struct Wrapper {
5966
var value : Builtin.Int32
6067
}
6168

62-
// CHECK-LABEL: sil @tbaa_class_alias_nonclass
69+
// CHECK-FUTURE: sil @tbaa_class_alias_nonclass
6370
// CHECK: strong_retain [[RET:%[0-9]+]]
6471
// CHECK: strong_retain [[RET]]
6572
// CHECK: return
@@ -79,7 +86,7 @@ bb0(%0 : $B, %1 : $*Agg1):
7986
}
8087

8188
// FIXME: When RLE uses TBAA it should remove the second load.
82-
// CHECK-LABEL: sil @tbaa_struct
89+
// CHECK-FUTURE: sil @tbaa_struct
8390
// CHECK: load
8491
// CHECK: store
8592
// CHECK: load
@@ -96,7 +103,7 @@ bb0(%0 : $Builtin.RawPointer, %1 : $A2):
96103
}
97104

98105
// Even with TBAA, RLE should not remove the second load.
99-
// CHECK-LABEL: sil @tbaa_bind_memory
106+
// CHECK-FUTURE: sil @tbaa_bind_memory
100107
// CHECK: load
101108
// CHECK: bind_memory
102109
// CHECK: store
@@ -118,7 +125,7 @@ bb0(%0 : $Builtin.RawPointer, %1 : $A2):
118125
}
119126

120127
// *NOTE* This does not handle raw pointer since raw pointer is only layout compatible with heap references.
121-
// CHECK-LABEL: sil @store_to_load_forward_unchecked_addr_cast_struct : $@convention(thin) (Optional<A>) -> () {
128+
// CHECK-FUTURE: sil @store_to_load_forward_unchecked_addr_cast_struct : $@convention(thin) (Optional<A>) -> () {
122129
// CHECK: bb0([[INPUT:%[0-9]+]]
123130
// CHECK-NEXT: [[LOCAL:%[0-9]+]] = alloc_stack
124131
// CHECK: unchecked_trivial_bit_cast [[INPUT]] : $Optional<A> to $Builtin.Int32
@@ -161,7 +168,7 @@ struct IntPtr {
161168
// source type is known to be greater or equal to the size of the
162169
// destination type.
163170
//
164-
// CHECK-LABEL: sil @store_to_load_forward_unchecked_addr_cast_nopromote : $@convention(thin) (@inout IntPtr) -> () {
171+
// CHECK-FUTURE: sil @store_to_load_forward_unchecked_addr_cast_nopromote : $@convention(thin) (@inout IntPtr) -> () {
165172
// CHECK: bb0([[INPUT:%[0-9]+]] : $*IntPtr)
166173
// CHECK-NEXT: [[LOCAL:%[0-9]+]] = alloc_stack
167174
// CHECK: [[CAST:%[0-9]+]] = unchecked_addr_cast [[INPUT]] : $*IntPtr to $*Builtin.Int32
@@ -185,7 +192,7 @@ bb0(%0 : $*IntPtr):
185192
// compatible with heap references, but does not have reference
186193
// semantics b/c it is a trivial type. We currently do not handle such a case.
187194

188-
// CHECK-LABEL: sil @store_to_load_forward_unchecked_addr_cast_class : $@convention(thin) (Optional<B>) -> () {
195+
// CHECK-FUTURE: sil @store_to_load_forward_unchecked_addr_cast_class : $@convention(thin) (Optional<B>) -> () {
189196
// CHECK: bb0([[INPUT:%[0-9]+]]
190197
// CHECK-NEXT: [[LOCAL:%[0-9]+]] = alloc_stack
191198
// CHECK: unchecked_trivial_bit_cast [[INPUT]] : $Optional<B> to $Builtin.Int32
@@ -221,7 +228,7 @@ bb0(%0 : $Optional<B>):
221228
}
222229

223230
// *NOTE* This does not handle raw pointer since raw pointer is only layout compatible with heap references.
224-
// CHECK-LABEL: sil @load_to_load_forward_unchecked_addr_cast_struct : $@convention(thin) (@inout Optional<A>) -> () {
231+
// CHECK-FUTURE: sil @load_to_load_forward_unchecked_addr_cast_struct : $@convention(thin) (@inout Optional<A>) -> () {
225232
// CHECK: bb0(
226233

227234
// CHECK: unchecked_trivial_bit_cast {{%[0-9]+}} : $Optional<A> to $Builtin.Int32
@@ -256,7 +263,7 @@ bb0(%0 : $*Optional<A>):
256263
// compatible with heap references, but does not have reference
257264
// semantics b/c it is a trivial type. We currently do not handle such a case.
258265

259-
// CHECK-LABEL: sil @load_to_load_forward_unchecked_addr_cast_class : $@convention(thin) (@inout Optional<B>) -> () {
266+
// CHECK-FUTURE: sil @load_to_load_forward_unchecked_addr_cast_class : $@convention(thin) (@inout Optional<B>) -> () {
260267
// CHECK: bb0({{%[0-9]+}} : $*Optional<B>):
261268
// CHECK: unchecked_trivial_bit_cast {{%[0-9]+}} : $Optional<B> to $Builtin.Int32
262269
// CHECK: unchecked_ref_bit_cast {{%[0-9]+}} : $Optional<B> to $B
@@ -287,7 +294,7 @@ bb0(%0 : $*Optional<B>):
287294
}
288295

289296
// Don't bitcast differently sized structs.
290-
// CHECK-LABEL: sil @store_to_load_forward_unchecked_addr_cast_different_sized_struct
297+
// CHECK-FUTURE: sil @store_to_load_forward_unchecked_addr_cast_different_sized_struct
291298
// CHECK-NOT: unchecked_trivial_bit_cast
292299
// CHECK: return
293300
sil @store_to_load_forward_unchecked_addr_cast_different_sized_struct : $@convention(thin) (C) -> () {
@@ -303,7 +310,7 @@ bb0(%0 : $C):
303310

304311

305312
/// Make sure that we don't crash and don't optimize here.
306-
// CHECK-LABEL: sil @covering_store_with_unchecked_addr : $@convention(thin) (C, C) -> () {
313+
// CHECK-FUTURE: sil @covering_store_with_unchecked_addr : $@convention(thin) (C, C) -> () {
307314
// CHECK-NOT: unchecked_trivial_bit_cast
308315
// CHECK: unchecked_addr_cast
309316
// CHECK-NOT: unchecked_trivial_bit_cast
@@ -338,7 +345,7 @@ bb3:
338345
/// 4. %5 can write to memory, so we try to check if it can alias %0#1. We look
339346
/// up the load that was erased and will use it in a memory unsafe way.
340347
//
341-
// CHECK-LABEL: sil @invalidate_dead_loads_with_only_store_user_correctly : $@convention(thin) () -> () {
348+
// CHECK-FUTURE: sil @invalidate_dead_loads_with_only_store_user_correctly : $@convention(thin) () -> () {
342349
// CHECK-NOT: load
343350
// CHECK-NOT: {{%.*}} = store
344351
sil @invalidate_dead_loads_with_only_store_user_correctly : $@convention(thin) () -> () {
@@ -361,7 +368,7 @@ sil @mutator : $@convention(method) (@inout HoldsRef) -> ()
361368

362369
// Ensure we don't forward the stored value from the switch_enum
363370
// branches past the inout appearance of the stored-to location.
364-
// CHECK-LABEL: sil @bad_store_forward
371+
// CHECK-FUTURE: sil @bad_store_forward
365372
sil @bad_store_forward : $@convention(thin) (@guaranteed Optional<HoldsRef>) -> () {
366373
// CHECK: bb0
367374
bb0(%0 : $Optional<HoldsRef>):
@@ -409,7 +416,7 @@ bb3:
409416
// We internally use a map vector to represent stores. This means that when we iterate over
410417
// the stores it should be in insertion order. Use this to test whether or not we only set
411418
// the no-dependency bit if we do not forward a load.
412-
// CHECK-LABEL: sil @test_unchecked_addr_cast_3
419+
// CHECK-FUTURE: sil @test_unchecked_addr_cast_3
413420
// CHECK: bb0([[ARG1:%.*]] : $D, [[ARG2:%.*]] : $D):
414421
// CHECK-NEXT: [[BOX1:%.*]] = alloc_stack $D
415422
// CHECK-NEXT: [[BOX2:%.*]] = alloc_stack $D
@@ -441,7 +448,7 @@ typealias I32 = Builtin.Int32
441448
// ((A, B), C) -> (A, B) is safe
442449
// ((A, B), C) -> (A, B, C) is NOT safe
443450
//
444-
// CHECK-LABEL: sil @unchecked_addr_cast_tuple_promote
451+
// CHECK-FUTURE: sil @unchecked_addr_cast_tuple_promote
445452
// CHECK: bb0(%0 : $*(Builtin.Int32, Builtin.Int32, Builtin.Int32), %1 : $*((Builtin.Int32, Builtin.Int32), Builtin.Int32)):
446453
// CHECK: load %0 : $*(Builtin.Int32, Builtin.Int32, Builtin.Int32)
447454
// CHECK: alloc_stack $(Builtin.Int32, Builtin.Int32, Builtin.Int32)
@@ -512,7 +519,7 @@ bb0(%0 : $*(I32, I32, I32), %1 : $*((I32, I32), I32)):
512519
// ((A, B), C) -> (A, B) is safe
513520
// ((A, B), C) -> (A, B, C) is NOT safe
514521
//
515-
// CHECK-LABEL: sil @forward_tuple_elements
522+
// CHECK-FUTURE: sil @forward_tuple_elements
516523
// CHECK: tuple_element_addr
517524
// CHECK: tuple_element_addr
518525
// CHECK: tuple_element_addr

0 commit comments

Comments
 (0)