@@ -24,6 +24,119 @@ bb0(%0 : @unowned $@convention(block) @noescape () -> ()):
24
24
return %7
25
25
}
26
26
27
+ // CHECK-LABEL: sil [ossa] @remove_copy_block_with_partial_apply :
28
+ // CHECK-NOT: copy_block
29
+ // CHECK: [[B:%.*]] = unchecked_ownership_conversion %0, @unowned to @guaranteed
30
+ // CHECK: [[PA:%.*]] = partial_apply [callee_guaranteed] [on_stack] {{%[0-9]+}}([[B]])
31
+ // CHECK: destroy_value [[PA]]
32
+ // CHECK-NOT: destroy_value
33
+ // CHECK: } // end sil function 'remove_copy_block_with_partial_apply'
34
+ sil [ossa] @remove_copy_block_with_partial_apply : $@convention(thin) (@convention(block) @noescape () -> ()) -> () {
35
+ bb0(%0 : @unowned $@convention(block) @noescape () -> ()):
36
+ %2 = copy_block %0
37
+ %3 = function_ref @thunk : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
38
+ %4 = partial_apply [callee_guaranteed] [on_stack] %3(%2) : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
39
+ destroy_value %4
40
+ destroy_value %2
41
+ %7 = tuple ()
42
+ return %7
43
+ }
44
+
45
+ // CHECK-LABEL: sil [ossa] @remove_copy_block_with_partial_apply_guaranteed :
46
+ // CHECK-NOT: copy_block
47
+ // CHECK: [[PA:%.*]] = partial_apply [callee_guaranteed] [on_stack] {{%[0-9]+}}(%0)
48
+ // CHECK: destroy_value [[PA]]
49
+ // CHECK-NOT: destroy_value
50
+ // CHECK: } // end sil function 'remove_copy_block_with_partial_apply_guaranteed'
51
+ sil [ossa] @remove_copy_block_with_partial_apply_guaranteed : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> () {
52
+ bb0(%0 : @guaranteed $@convention(block) @noescape () -> ()):
53
+ %2 = copy_block %0
54
+ %3 = function_ref @thunk : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
55
+ %4 = partial_apply [callee_guaranteed] [on_stack] %3(%2) : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
56
+ destroy_value %4
57
+ destroy_value %2
58
+ %7 = tuple ()
59
+ return %7
60
+ }
61
+
62
+ // CHECK-LABEL: sil [ossa] @remove_copy_block_with_partial_apply_owned :
63
+ // CHECK-NOT: copy_block
64
+ // CHECK: [[PA:%.*]] = partial_apply [callee_guaranteed] [on_stack] {{%[0-9]+}}(%0)
65
+ // CHECK: } // end sil function 'remove_copy_block_with_partial_apply_owned'
66
+ sil [ossa] @remove_copy_block_with_partial_apply_owned : $@convention(thin) (@owned @convention(block) @noescape () -> ()) -> () {
67
+ bb0(%0 : @owned $@convention(block) @noescape () -> ()):
68
+ %2 = copy_block %0
69
+ %3 = function_ref @thunk : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
70
+ %4 = partial_apply [callee_guaranteed] [on_stack] %3(%2) : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
71
+ destroy_value %4
72
+ destroy_value %2
73
+ destroy_value %0
74
+ %7 = tuple ()
75
+ return %7
76
+ }
77
+
78
+ sil [ossa] @thunk : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> () {
79
+ bb0(%0 : @guaranteed $@convention(block) @noescape () -> ()):
80
+ %1 = apply %0() : $@convention(block) @noescape () -> ()
81
+ %2 = tuple ()
82
+ return %2
83
+ }
84
+
85
+ sil @use_closure : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
86
+
87
+ // CHECK-LABEL: sil [ossa] @dont_remove_copy_block_with_escaping_partial_apply :
88
+ // CHECK: copy_block
89
+ // CHECK: } // end sil function 'dont_remove_copy_block_with_escaping_partial_apply'
90
+ sil [ossa] @dont_remove_copy_block_with_escaping_partial_apply : $@convention(thin) (@convention(block) @noescape () -> ()) -> () {
91
+ bb0(%0 : @unowned $@convention(block) @noescape () -> ()):
92
+ %2 = copy_block %0
93
+ %3 = function_ref @thunk : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
94
+ %4 = partial_apply [callee_guaranteed] %3(%2) : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
95
+ %5 = function_ref @use_closure : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
96
+ apply %5(%4) : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
97
+ destroy_value %4
98
+ %7 = tuple ()
99
+ return %7
100
+ }
101
+
102
+ sil [ossa] @unknown_thunk : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
103
+
104
+ // CHECK-LABEL: sil [ossa] @dont_remove_copy_block_with_unknown_partial_apply :
105
+ // CHECK: copy_block
106
+ // CHECK: } // end sil function 'dont_remove_copy_block_with_unknown_partial_apply'
107
+ sil [ossa] @dont_remove_copy_block_with_unknown_partial_apply : $@convention(thin) (@convention(block) @noescape () -> ()) -> () {
108
+ bb0(%0 : @unowned $@convention(block) @noescape () -> ()):
109
+ %2 = copy_block %0
110
+ %3 = function_ref @unknown_thunk : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
111
+ %4 = partial_apply [callee_guaranteed] [on_stack] %3(%2) : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
112
+ destroy_value %4
113
+ destroy_value %2
114
+ %7 = tuple ()
115
+ return %7
116
+ }
117
+
118
+ // CHECK-LABEL: sil [ossa] @dont_remove_copy_block_with_partial_apply_escaping :
119
+ // CHECK: copy_block
120
+ // CHECK: } // end sil function 'dont_remove_copy_block_with_partial_apply_escaping'
121
+ sil [ossa] @dont_remove_copy_block_with_partial_apply_escaping : $@convention(thin) (@convention(block) @noescape () -> ()) -> () {
122
+ bb0(%0 : @unowned $@convention(block) @noescape () -> ()):
123
+ %2 = copy_block %0
124
+ %3 = function_ref @thunk_escaping : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
125
+ %4 = partial_apply [callee_guaranteed] [on_stack] %3(%2) : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> ()
126
+ destroy_value %4
127
+ destroy_value %2
128
+ %7 = tuple ()
129
+ return %7
130
+ }
131
+
132
+ sil [ossa] @thunk_escaping : $@convention(thin) (@guaranteed @convention(block) @noescape () -> ()) -> () {
133
+ bb0(%0 : @guaranteed $@convention(block) @noescape () -> ()):
134
+ %1 = function_ref @use_block : $@convention(thin) (@convention(block) @noescape () -> ()) -> ()
135
+ %2 = apply %1(%0) : $@convention(thin) (@convention(block) @noescape () -> ()) -> ()
136
+ %3 = tuple ()
137
+ return %3
138
+ }
139
+
27
140
// CHECK-LABEL: sil [ossa] @dont_remove_copied_block :
28
141
// CHECK: copy_block
29
142
// CHECK: } // end sil function 'dont_remove_copied_block'
0 commit comments