Skip to content

Commit a3fa246

Browse files
committed
[Test] Adjusted SIL tests.
Changes to teach the optimizer pipeline about move_value require some corresponding test updates.
1 parent 10e86d6 commit a3fa246

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

test/SILOptimizer/arc_crash.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class Base {
1515
public class Node : Base {
1616
var node: Base
1717

18+
@inline(never)
1819
init(node: Base) { self.node = node }
1920
}
2021
struct Queue {

test/SILOptimizer/semantic-arc-opts.sil

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ bb3(%7 : @owned $FakeOptional<Builtin.NativeObject>):
15291529

15301530
// SemanticARCOptVisitor::performGuaranteedCopyValueOptimization should not optimize this case.
15311531
//
1532-
// CHECK-LABEL: sil [ossa] @testDeadInterleavedBorrow : $@convention(c) (@owned FakeOptional<AnyObject>) -> () {
1532+
// CHECK-LABEL: sil [ossa] @testDeadInterleavedBorrow : $@convention(c) () -> () {
15331533
// CHECK: [[B:%.*]] = begin_borrow [lexical] %0 : $FakeOptional<AnyObject>
15341534
// CHECK: copy_value
15351535
// CHECK: switch_enum
@@ -1539,8 +1539,9 @@ bb3(%7 : @owned $FakeOptional<Builtin.NativeObject>):
15391539
// CHECK: end_borrow
15401540
// CHECK: destroy_value [[COPY]] : $AnyObject
15411541
// CHECK-LABEL: } // end sil function 'testDeadInterleavedBorrow'
1542-
sil [ossa] @testDeadInterleavedBorrow : $@convention(c) (@owned FakeOptional<AnyObject>) -> () {
1543-
bb0(%opt : @owned $FakeOptional<AnyObject>):
1542+
sil [ossa] @testDeadInterleavedBorrow : $@convention(c) () -> () {
1543+
bb0:
1544+
%opt = apply undef() : $@convention(thin) () -> (@owned FakeOptional<AnyObject>)
15441545
%opt_borrow = begin_borrow [lexical] %opt : $FakeOptional<AnyObject>
15451546
%opt_borrow_copy = copy_value %opt_borrow : $FakeOptional<AnyObject>
15461547
switch_enum %opt_borrow_copy : $FakeOptional<AnyObject>, case #FakeOptional.some!enumelt: some, case #FakeOptional.none!enumelt: none
@@ -1567,7 +1568,7 @@ exit:
15671568

15681569
// SemanticARCOptVisitor::performGuaranteedCopyValueOptimization should not optimize this case.
15691570
//
1570-
// CHECK-LABEL: sil [ossa] @testDeadAndAliveInterleavedBorrow : $@convention(c) (@owned FakeOptional<AnyObject>) -> () {
1571+
// CHECK-LABEL: sil [ossa] @testDeadAndAliveInterleavedBorrow : $@convention(c) () -> () {
15711572
// CHECK: [[B:%.*]] = begin_borrow [lexical] %0 : $FakeOptional<AnyObject>
15721573
// CHECK: copy_value
15731574
// CHECK: switch_enum
@@ -1586,8 +1587,9 @@ exit:
15861587
// CHECK: destroy_value [[COPY]] : $AnyObject
15871588
// CHECK: destroy_value %0 : $FakeOptional<AnyObject>
15881589
// CHECK-LABEL: } // end sil function 'testDeadAndAliveInterleavedBorrow'
1589-
sil [ossa] @testDeadAndAliveInterleavedBorrow : $@convention(c) (@owned FakeOptional<AnyObject>) -> () {
1590-
bb0(%opt : @owned $FakeOptional<AnyObject>):
1590+
sil [ossa] @testDeadAndAliveInterleavedBorrow : $@convention(c) () -> () {
1591+
bb0:
1592+
%opt = apply undef() : $@convention(thin) () -> (@owned FakeOptional<AnyObject>)
15911593
%opt_borrow = begin_borrow [lexical] %opt : $FakeOptional<AnyObject>
15921594
%opt_borrow_copy = copy_value %opt_borrow : $FakeOptional<AnyObject>
15931595
switch_enum %opt_borrow_copy : $FakeOptional<AnyObject>, case #FakeOptional.some!enumelt: some, case #FakeOptional.none!enumelt: none

test/SILOptimizer/sil_combine_protocol_conf.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ public class OtherClass {
248248
// CHECK: load [[S11]]
249249
// CHECK: [[R2:%.*]] = ref_element_addr [[ARG]] : $OtherClass, #OtherClass.arg2
250250
// CHECK: [[ACC2:%.*]] = begin_access [read] [static] [no_nested_conflict] [[R2]]
251-
// CHECK: copy_addr [[ACC2]] to [init] [[T1:%[0-9]*]]
252-
// CHECK: [[O2:%.*]] = open_existential_addr immutable_access [[T1]] : $*any GenericPropProtocol to $*@opened("{{.*}}", any GenericPropProtocol) Self
251+
// CHECK: [[O2:%.*]] = open_existential_addr immutable_access [[ACC2]] : $*any GenericPropProtocol to $*@opened("{{.*}}", any GenericPropProtocol) Self
252+
// CHECK: copy_addr [[O2]] to [init] [[T1:%[0-9]*]]
253253
// CHECK: [[W2:%.*]] = witness_method $@opened("{{.*}}", any GenericPropProtocol) Self, #GenericPropProtocol.val!getter : <Self where Self : GenericPropProtocol> (Self) -> () -> Int, [[O2]] : $*@opened("{{.*}}", any GenericPropProtocol) Self : $@convention(witness_method: GenericPropProtocol) <τ_0_0 where τ_0_0 : GenericPropProtocol> (@in_guaranteed τ_0_0) -> Int
254-
// CHECK: apply [[W2]]<@opened("{{.*}}", any GenericPropProtocol) Self>([[O2]]) : $@convention(witness_method: GenericPropProtocol) <τ_0_0 where τ_0_0 : GenericPropProtocol> (@in_guaranteed τ_0_0) -> Int
254+
// CHECK: apply [[W2]]<@opened("{{.*}}", any GenericPropProtocol) Self>([[T1]]) : $@convention(witness_method: GenericPropProtocol) <τ_0_0 where τ_0_0 : GenericPropProtocol> (@in_guaranteed τ_0_0) -> Int
255255
// CHECK: struct_extract
256256
// CHECK: integer_literal
257257
// CHECK: builtin
@@ -271,10 +271,10 @@ public class OtherClass {
271271
// CHECK: cond_fail
272272
// CHECK: [[R5:%.*]] = ref_element_addr [[ARG]] : $OtherClass, #OtherClass.arg4
273273
// CHECK: [[ACC5:%.*]] = begin_access [read] [static] [no_nested_conflict] [[R5]]
274-
// CHECK: copy_addr [[ACC5]] to [init] [[T2:%[0-9]+]]
275-
// CHECK: [[O5:%.*]] = open_existential_addr immutable_access [[T2]] : $*any GenericNestedPropProtocol to $*@opened("{{.*}}", any GenericNestedPropProtocol) Self
274+
// CHECK: [[O5:%.*]] = open_existential_addr immutable_access [[ACC5]] : $*any GenericNestedPropProtocol to $*@opened("{{.*}}", any GenericNestedPropProtocol) Self
275+
// CHECK: copy_addr [[O5]] to [init] [[T2:%[0-9]+]]
276276
// CHECK: [[W5:%.*]] = witness_method $@opened("{{.*}}", any GenericNestedPropProtocol) Self, #GenericNestedPropProtocol.val!getter : <Self where Self : GenericNestedPropProtocol> (Self) -> () -> Int, [[O5:%.*]] : $*@opened("{{.*}}", any GenericNestedPropProtocol) Self : $@convention(witness_method: GenericNestedPropProtocol) <τ_0_0 where τ_0_0 : GenericNestedPropProtocol> (@in_guaranteed τ_0_0) -> Int
277-
// CHECK: apply [[W5]]<@opened("{{.*}}", any GenericNestedPropProtocol) Self>([[O5]]) : $@convention(witness_method: GenericNestedPropProtocol) <τ_0_0 where τ_0_0 : GenericNestedPropProtocol> (@in_guaranteed τ_0_0) -> Int
277+
// CHECK: apply [[W5]]<@opened("{{.*}}", any GenericNestedPropProtocol) Self>([[T2]]) : $@convention(witness_method: GenericNestedPropProtocol) <τ_0_0 where τ_0_0 : GenericNestedPropProtocol> (@in_guaranteed τ_0_0) -> Int
278278
// CHECK: struct_extract
279279
// CHECK: builtin
280280
// CHECK: tuple_extract
@@ -341,10 +341,10 @@ public class OtherKlass {
341341
// CHECK: integer_literal
342342
// CHECK: [[R1:%.*]] = ref_element_addr [[ARG]] : $OtherKlass, #OtherKlass.arg2
343343
// CHECK: [[ACC1:%.*]] = begin_access [read] [static] [no_nested_conflict] [[R1]]
344-
// CHECK: copy_addr [[ACC1]] to [init] [[T1:%[0-9]+]]
345-
// CHECK: [[O1:%.*]] = open_existential_addr immutable_access [[T1]] : $*any AGenericProtocol to $*@opened("{{.*}}", any AGenericProtocol) Self
344+
// CHECK: [[O1:%.*]] = open_existential_addr immutable_access [[ACC1]] : $*any AGenericProtocol to $*@opened("{{.*}}", any AGenericProtocol) Self
345+
// CHECK: copy_addr [[O1]] to [init] [[T1:%[0-9]+]]
346346
// CHECK: [[W1:%.*]] = witness_method $@opened("{{.*}}", any AGenericProtocol) Self, #AGenericProtocol.val!getter : <Self where Self : AGenericProtocol> (Self) -> () -> Int, [[O1]] : $*@opened("{{.*}}", any AGenericProtocol) Self : $@convention(witness_method: AGenericProtocol) <τ_0_0 where τ_0_0 : AGenericProtocol> (@in_guaranteed τ_0_0) -> Int
347-
// CHECK: apply [[W1]]<@opened("{{.*}}", any AGenericProtocol) Self>([[O1]]) : $@convention(witness_method: AGenericProtocol) <τ_0_0 where τ_0_0 : AGenericProtocol> (@in_guaranteed τ_0_0) -> Int
347+
// CHECK: apply [[W1]]<@opened("{{.*}}", any AGenericProtocol) Self>([[T1]]) : $@convention(witness_method: AGenericProtocol) <τ_0_0 where τ_0_0 : AGenericProtocol> (@in_guaranteed τ_0_0) -> Int
348348
// CHECK: struct_extract
349349
// CHECK: integer_literal
350350
// CHECK: builtin

test/SILOptimizer/type_wrapper_init_transform.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ struct TupleFlatteningTest<K: Collection & Hashable, V> {
129129
// CHECK: [[STORAGE_VAR:%.*]] = alloc_stack $TupleFlatteningTest<K, V>.$Storage
130130
// CHECK: [[STORAGE_INIT_REF:%.*]] = function_ref @$s4test19TupleFlatteningTestV8$StorageV1a1b1c1dAEyxq__GSi_SS_Si_xttSDyxq_Gq_SgtcfC
131131
// CHECK: [[LOCAL_STORAGE_ACCESS:%.*]] = begin_access [read] [unsafe] [[LOCAL_STORAGE:%.*]] : $*(a: Int, b: (String, (Int, K)), c: Dictionary<K, V>, d: Optional<V>)
132-
// CHECK: [[A_REF:%.*]] = tuple_element_addr %73 : $*(a: Int, b: (String, (Int, K)), c: Dictionary<K, V>, d: Optional<V>), 0
132+
// CHECK: [[A_REF:%.*]] = tuple_element_addr {{%[^,]+}} : $*(a: Int, b: (String, (Int, K)), c: Dictionary<K, V>, d: Optional<V>), 0
133133
// CHECK: [[A:%.*]] = load [trivial] [[A_REF]] : $*Int
134134
// CHECK: [[B_TUPLE:%.*]] = tuple_element_addr [[LOCAL_STORAGE_ACCESS]] : $*(a: Int, b: (String, (Int, K)), c: Dictionary<K, V>, d: Optional<V>), 1
135135
// CHECK: [[B_ELT_0_REF:%.*]] = tuple_element_addr [[B_TUPLE]] : $*(String, (Int, K)), 0
@@ -354,7 +354,7 @@ struct TypeWithLetProperties<T> {
354354
public init(a: T, b: Int? = nil, onSet: (() -> Void)? = nil) {
355355
// CHECK: [[LOCAL_STORAGE_ACCESS:%.*]] = begin_access [modify] [static] [[LOCAL_STORAGE]] : $*(a: T, b: Int)
356356
// CHECK-NEXT: [[A_REF:%.*]] = tuple_element_addr [[LOCAL_STORAGE_ACCESS]] : $*(a: T, b: Int), 0
357-
// CHECK-NEXT: copy_addr [take] %11 to [init] [[A_REF]] : $*T
357+
// CHECK-NEXT: copy_addr [take] {{%[^,]+}} to [init] [[A_REF]] : $*T
358358
// CHECK-NOT: {{.*}} = assign_by_wrapper {{.*}}
359359
// CHECK-NEXT: end_access [[LOCAL_STORAGE_ACCESS]]
360360
self.a = a
@@ -444,7 +444,7 @@ struct TypeWithDefaultedProperties<T> {
444444
// --> Assignment to `let a`
445445
// CHECK: [[LOCAL_STORAGE_ACCESS:%.*]] = begin_access [modify] [static] [[LOCAL_STORAGE]] : $*(a: Array<String>, b: Optional<T>, c: Int)
446446
// CHECK-NEXT: [[A_REF:%.*]] = tuple_element_addr [[LOCAL_STORAGE_ACCESS]] : $*(a: Array<String>, b: Optional<T>, c: Int), 0
447-
// CHECK-NEXT: assign [[A_ARG:%.*]] to [init] %18 : $*Array<String>
447+
// CHECK-NEXT: assign [[A_ARG:%.*]] to [init] {{%[^,]+}} : $*Array<String>
448448
// CHECK-NEXT: end_access [[LOCAL_STORAGE_ACCESS]]
449449
// --> Assignment to `var c`, note that the assignment is done to a wrapped value
450450
// CHECK: [[C_REF:%.*]] = tuple_element_addr [[LOCAL_STORAGE]] : $*(a: Array<String>, b: Optional<T>, c: Int), 2

0 commit comments

Comments
 (0)