Skip to content

Commit 775e28f

Browse files
committed
[SILOptimizer] Adds test cases for the escaping analysis of .
1 parent 35f82ba commit 775e28f

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/SILOptimizer/escape_info.sil

+39
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,45 @@ bb0:
14581458
return %2 : $X
14591459
}
14601460

1461+
// CHECK-LABEL: Escape information for test_unchecked_ref_cast_from_optional_to_non_optional:
1462+
// CHECK: return[]: %0 = alloc_ref $Derived
1463+
// CHECK: - : %2 = alloc_ref $Derived
1464+
// CHECK: End function test_unchecked_ref_cast_from_optional_to_non_optional
1465+
sil @test_unchecked_ref_cast_from_optional_to_non_optional : $@convention(thin) () -> @owned X {
1466+
bb0:
1467+
%0 = alloc_ref $Derived
1468+
%1 = enum $Optional<Derived>, #Optional.some!enumelt, %0 : $Derived
1469+
%2 = alloc_ref $Derived
1470+
%3 = enum $Optional<Derived>, #Optional.some!enumelt, %2 : $Derived
1471+
%4 = unchecked_ref_cast %1 : $Optional<Derived> to $X
1472+
%5 = unchecked_ref_cast %3 : $Optional<Derived> to $X
1473+
return %4 : $X
1474+
}
1475+
1476+
// CHECK-LABEL: Escape information for test_unchecked_ref_cast_from_optional_to_non_optional_2:
1477+
// CHECK-NEXT: End function test_unchecked_ref_cast_from_optional_to_non_optional_2
1478+
sil @test_unchecked_ref_cast_from_optional_to_non_optional_2 : $@convention(thin) () -> @owned X {
1479+
bb0:
1480+
%0 = enum $Optional<Derived>, #Optional.none!enumelt
1481+
%1 = enum $Optional<Derived>, #Optional.none!enumelt
1482+
%2 = unchecked_ref_cast %0 : $Optional<Derived> to $X
1483+
%3 = unchecked_ref_cast %1 : $Optional<Derived> to $X
1484+
return %2 : $X
1485+
}
1486+
1487+
// CHECK-LABEL: Escape information for test_unchecked_ref_cast_from_non_optional_to_optional:
1488+
// CHECK: return[e1]: %0 = alloc_ref $Derived
1489+
// CHECK: - : %1 = alloc_ref $Derived
1490+
// CHECK: End function test_unchecked_ref_cast_from_non_optional_to_optional
1491+
sil @test_unchecked_ref_cast_from_non_optional_to_optional : $@convention(thin) () -> @owned Optional<X> {
1492+
bb0:
1493+
%0 = alloc_ref $Derived
1494+
%1 = alloc_ref $Derived
1495+
%2 = unchecked_ref_cast %0 : $Derived to $Optional<X>
1496+
%3 = unchecked_ref_cast %1 : $Derived to $Optional<X>
1497+
return %2 : $Optional<X>
1498+
}
1499+
14611500
// CHECK-LABEL: Escape information for test_unchecked_addr_cast:
14621501
// CHECK: global: %1 = alloc_ref $X
14631502
// CHECK: End function test_unchecked_addr_cast

0 commit comments

Comments
 (0)