Skip to content

Commit 43d21cc

Browse files
committed
RLE tests for boundary Projection indices.
1 parent 7b208ae commit 43d21cc

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

test/SILOptimizer/redundant_load_elim.sil

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,14 +1176,27 @@ bb0(%0 : $*Builtin.Int64, %1 : $Builtin.NativeObject):
11761176
return %6 : $(Builtin.Int64, Builtin.Int64)
11771177
}
11781178

1179-
sil @dont_crash_on_index_addr_projection : $@convention(thin) (Builtin.RawPointer) -> Int {
1179+
sil @dont_crash_on_index_addr_projection : $@convention(thin) (Builtin.RawPointer) -> (Int, Int, Int, Int) {
11801180
bb0(%0 : $Builtin.RawPointer):
1181-
%3 = integer_literal $Builtin.Word, 4294967295
1181+
// Negative (valid constant index)
1182+
%3 = integer_literal $Builtin.Word, 4294967295 // '0xffffffff'
11821183
%4 = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*Int
1183-
// Just check if we can handle an index_addr projection with the special value of 0xffffffff
11841184
%5 = index_addr %4 : $*Int, %3 : $Builtin.Word
11851185
%6 = load %5 : $*Int
1186-
return %6 : $Int
1186+
// TailIndex (invalid constant index)
1187+
%7 = integer_literal $Builtin.Word, 2147483647 // '0x7fffffff'
1188+
%8 = index_addr %4 : $*Int, %7 : $Builtin.Word
1189+
%9 = load %8 : $*Int
1190+
// UnknownOffset (valid index)
1191+
%10 = integer_literal $Builtin.Word, 3221225472 // '0xC0000000'
1192+
%11 = index_addr %4 : $*Int, %10 : $Builtin.Word
1193+
%12 = load %11 : $*Int
1194+
// Root (unused/invalid index))
1195+
%13 = integer_literal $Builtin.Word, 2147483648 // '0x80000000'
1196+
%14 = index_addr %4 : $*Int, %13 : $Builtin.Word
1197+
%15 = load %14 : $*Int
1198+
%99 = tuple (%6 : $Int, %9 : $Int, %12 : $Int, %15 : $Int)
1199+
return %99 : $(Int, Int, Int, Int)
11871200
}
11881201

11891202
sil @overwrite_int : $@convention(thin) (@inout Int, Int) -> ()

0 commit comments

Comments
 (0)