@@ -27,6 +27,14 @@ class MyArrayContainer<T> {
27
27
deinit
28
28
}
29
29
30
+ struct Container {
31
+ var array: MyArray<MyStruct>
32
+ }
33
+
34
+ struct ContainerContainer {
35
+ var container: Container
36
+ }
37
+
30
38
sil [_semantics "array.make_mutable"] @array_make_mutable : $@convention(method) (@inout MyArray<MyStruct>) -> ()
31
39
sil [_semantics "array.get_count"] @guaranteed_array_get_count : $@convention(method) (@guaranteed MyArray<MyStruct>) -> Int
32
40
sil [_semantics "array.get_capacity"] @guaranteed_array_get_capacity : $@convention(method) (@guaranteed MyArray<MyStruct>) -> Int
@@ -1013,3 +1021,84 @@ bb6(%23 : $Builtin.Int64):
1013
1021
%73 = apply %72() : $@convention(thin) () -> ()
1014
1022
cond_br undef, bb5, bb6(%26 : $Builtin.Int64)
1015
1023
}
1024
+
1025
+ // CHECK-LABEL: sil @hoist_projections
1026
+ // CHECK: bb0([[CONTAINER:%[0-9]+]]
1027
+ // CHECK: [[CONTAINER2:%.*]] = struct_element_addr [[CONTAINER]] : $*ContainerContainer
1028
+ // CHECK: [[ARRAY:%.*]] = struct_element_addr [[CONTAINER2]] : $*Container,
1029
+ // CHECK: [[FUN:%[0-9]+]] = function_ref @array_make_mutable
1030
+ // CHECK: apply [[FUN]]([[ARRAY]]
1031
+ // CHECK: bb1
1032
+ // CHECK-NOT: array_make_mutable
1033
+ // CHECK-NOT: apply [[FUN]]
1034
+ sil @hoist_projections : $@convention(thin) (@inout ContainerContainer, @inout Builtin.Int1) -> () {
1035
+ bb0(%0 : $*ContainerContainer, %1 : $*Builtin.Int1):
1036
+ br bb1
1037
+
1038
+ bb1:
1039
+ %2 = struct_element_addr %0 : $*ContainerContainer, #ContainerContainer.container
1040
+ br bb3(%2 : $*Container)
1041
+
1042
+ bb3(%3: $*Container):
1043
+ %4 = struct_element_addr %3 : $*Container, #Container.array
1044
+ %5 = function_ref @array_make_mutable : $@convention(method) (@inout MyArray<MyStruct>) -> ()
1045
+ %6 = apply %5(%4) : $@convention(method) (@inout MyArray<MyStruct>) -> ()
1046
+ cond_br undef, bb1, bb2
1047
+
1048
+ bb2:
1049
+ %7 = tuple()
1050
+ return %7 : $()
1051
+ }
1052
+
1053
+ // CHECK-LABEL: sil @hoist_projections2
1054
+ // CHECK: bb0([[CONTAINER:%[0-9]+]]
1055
+ // CHECK: [[CONTAINER2:%.*]] = struct_element_addr [[CONTAINER]] : $*ContainerContainer
1056
+ // CHECK: [[ARRAY:%.*]] = struct_element_addr [[CONTAINER2]] : $*Container,
1057
+ // CHECK: [[FUN:%[0-9]+]] = function_ref @array_make_mutable
1058
+ // CHECK: apply [[FUN]]([[ARRAY]]
1059
+ // CHECK: bb1
1060
+ // CHECK-NOT: array_make_mutable
1061
+ // CHECK-NOT: apply [[FUN]]
1062
+ sil @hoist_projections2 : $@convention(thin) (@inout ContainerContainer, @inout Builtin.Int1) -> () {
1063
+ bb0(%0 : $*ContainerContainer, %1 : $*Builtin.Int1):
1064
+ br bb1
1065
+
1066
+ bb1:
1067
+ %2 = struct_element_addr %0 : $*ContainerContainer, #ContainerContainer.container
1068
+ %3 = struct_element_addr %2 : $*Container, #Container.array
1069
+ br bb3(%3 : $*MyArray<MyStruct>)
1070
+
1071
+ bb3(%4 : $*MyArray<MyStruct>):
1072
+ %5 = function_ref @array_make_mutable : $@convention(method) (@inout MyArray<MyStruct>) -> ()
1073
+ %6 = apply %5(%4) : $@convention(method) (@inout MyArray<MyStruct>) -> ()
1074
+ cond_br undef, bb1, bb2
1075
+
1076
+ bb2:
1077
+ %7 = tuple()
1078
+ return %7 : $()
1079
+ }
1080
+
1081
+ // CHECK-LABEL: sil @hoist_projections3
1082
+ // CHECK: bb0([[CONTAINER:%[0-9]+]]
1083
+ // CHECK: [[CONTAINER2:%.*]] = struct_element_addr [[CONTAINER]] : $*ContainerContainer
1084
+ // CHECK: [[ARRAY:%.*]] = struct_element_addr [[CONTAINER2]] : $*Container,
1085
+ // CHECK: [[FUN:%[0-9]+]] = function_ref @array_make_mutable
1086
+ // CHECK: apply [[FUN]]([[ARRAY]]
1087
+ // CHECK: bb1
1088
+ // CHECK-NOT: array_make_mutable
1089
+ // CHECK-NOT: apply [[FUN]]
1090
+ sil @hoist_projections3 : $@convention(thin) (@inout ContainerContainer, @inout Builtin.Int1) -> () {
1091
+ bb0(%0 : $*ContainerContainer, %1 : $*Builtin.Int1):
1092
+ br bb1
1093
+
1094
+ bb1:
1095
+ %2 = struct_element_addr %0 : $*ContainerContainer, #ContainerContainer.container
1096
+ %3 = struct_element_addr %2 : $*Container, #Container.array
1097
+ %5 = function_ref @array_make_mutable : $@convention(method) (@inout MyArray<MyStruct>) -> ()
1098
+ %6 = apply %5(%3) : $@convention(method) (@inout MyArray<MyStruct>) -> ()
1099
+ cond_br undef, bb1, bb2
1100
+
1101
+ bb2:
1102
+ %7 = tuple()
1103
+ return %7 : $()
1104
+ }
0 commit comments