1
- // RUN: %target-sil-opt -O -wmo -enable-sil-verify-all %s | %FileCheck %s
1
+ // RUN: %target-sil-opt -O -wmo -enable-sil-verify-all -sil-disable-pass=DeadFunctionElimination %s | %FileCheck %s
2
2
3
3
sil_stage canonical
4
4
@@ -15,46 +15,42 @@ sil @test_indirect_class_protocol : $@convention(thin) (@in ClassProtocol) -> ()
15
15
bb0(%0 : $*ClassProtocol):
16
16
// CHECK-NEXT: %1 = load %0
17
17
// CHECK-NEXT: strong_release %1
18
- // CHECK-NEXT: strong_release %1
19
18
destroy_addr %0 : $*ClassProtocol
20
19
// CHECK-NEXT: return undef
21
20
return undef : $()
22
21
}
23
22
24
- // CHECK-LABEL: sil [signature_optimized_thunk] [always_inline] @test_indirect_class_protocol_guaranteed : $@convention(thin) (@in_guaranteed ClassProtocol) -> ()
25
- sil @test_indirect_class_protocol_guaranteed : $@convention(thin) (@in_guaranteed ClassProtocol ) -> () {
23
+ // Check that all the opened types are optimized away in the specialization of test_indirect_class_protocol_guaranteed
24
+ // CHECK-LABEL: sil shared @$s39test_indirect_class_protocol_guaranteedTf4e_n : $@convention(thin) <τ_0_0 where τ_0_0 : ClassProtocol> (@in_guaranteed τ_0_0 ) -> ()
26
25
// CHECK-NEXT: //
27
- // CHECK-NEXT: bb0(%0 : $*ClassProtocol):
26
+ // CHECK-NEXT: bb0(%0 : $*τ_0_0):
27
+ // CHECK-NEXT: [[INPUT:%1]] = load %0
28
+ // CHECK-NEXT: [[METHOD:%.*]] = witness_method $C, #ClassProtocol.method
29
+ // CHECK-NEXT: [[ARG:%.*]] = unchecked_ref_cast [[INPUT]]
30
+ // CHECK-NEXT: apply [[METHOD]]<C>([[ARG]])
31
+ // CHECK-NEXT: return undef
32
+
33
+ sil @test_indirect_class_protocol_guaranteed : $@convention(thin) (@in_guaranteed ClassProtocol) -> () {
28
34
bb0(%0 : $*ClassProtocol):
29
- // CHECK-NEXT: [[INPUT:%1]] = load %0
30
35
%1 = load %0 : $*ClassProtocol
31
- // CHECK-NEXT: [[OPENED:%.*]] = open_existential_ref [[INPUT]]
32
- // CHECK-NEXT: [[CLOSED:%.*]] = unchecked_ref_cast [[OPENED]]
33
36
%2 = open_existential_ref %1 : $ClassProtocol to $@opened("ABCDEF01-ABCD-ABCD-ABCD-ABCDEFABCDEF") ClassProtocol
34
- // CHECK-NEXT: [[METHOD:%.*]] = witness_method $C, #ClassProtocol.method
35
37
%f = witness_method $@opened("ABCDEF01-ABCD-ABCD-ABCD-ABCDEFABCDEF") ClassProtocol, #ClassProtocol.method!1 : <Self: ClassProtocol> (Self) -> () -> (), %2 : $@opened("ABCDEF01-ABCD-ABCD-ABCD-ABCDEFABCDEF") ClassProtocol : $@convention(witness_method : ClassProtocol) <Self: ClassProtocol> (@guaranteed Self) -> ()
36
- // CHECK-NEXT: apply [[METHOD]]<C>([[CLOSED]])
37
38
apply %f<@opened("ABCDEF01-ABCD-ABCD-ABCD-ABCDEFABCDEF") ClassProtocol>(%2) : $@convention(witness_method : ClassProtocol) <Self: ClassProtocol> (@guaranteed Self) -> ()
38
- // CHECK-NEXT: strong_release [[INPUT]]
39
- // CHECK-NEXT: return undef
40
39
return undef : $()
41
40
}
42
41
43
- // CHECK-LABEL: sil @invoke_indirect_class_protocol : $@convention(thin) (@guaranteed C) -> ()
44
-
45
- // Make sure both applies were inlined.
46
-
42
+ // Check that a specialization of test_indirect_class_protocol is created.
43
+ // CHECK-LABEL: sil shared [signature_optimized_thunk] [always_inline] @$s28test_indirect_class_protocolTf4e_n4main1CC_Tg5 : $@convention(thin) (@owned C) -> ()
47
44
// CHECK-NEXT: //
48
45
// CHECK-NEXT: bb0(%0 : $C):
49
-
50
- // CHECK-NEXT: [[METHOD:%.*]] = witness_method $C, #ClassProtocol.method
51
- // CHECK-NEXT: strong_retain %0
52
- // CHECK-NEXT: apply [[METHOD]]<C>(%0)
53
-
54
- // CHECK-NEXT: strong_release %0
55
- // CHECK-NEXT: strong_release %0
56
46
// CHECK-NEXT: strong_release %0
47
+ // CHECK-NEXT: return undef
48
+ // CHECK-LABEL: end sil function '$s28test_indirect_class_protocolTf4e_n4main1CC_Tg5'
57
49
50
+ // Check the generated specialization of test_indirect_class_protocol
51
+ // CHECK-LABEL: sil shared @$s28test_indirect_class_protocolTf4e_n4main1CC_Tg5Tf4d_n : $@convention(thin) () -> ()
52
+ // Make sure *everything* was inlined / optimized away
53
+ // CHECK-NEXT: bb0:
58
54
// CHECK-NEXT: return undef
59
55
60
56
sil @invoke_indirect_class_protocol : $@convention(thin) (@guaranteed C) -> () {
0 commit comments