Skip to content

Commit f37df42

Browse files
committed
[SILGen] A noEagerMove consuming param is lexical.
1 parent 2a3c533 commit f37df42

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/SILOptimizer/consuming_parameter.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,34 @@ public func async_dead_arg_call(o: consuming AnyObject) async {
1414
await bar()
1515
}
1616

17+
// CHECK-LABEL: sil [ossa] @async_dead_arg_call_lexical : {{.*}} {
18+
// CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : @_lexical @owned
19+
// CHECK: [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]]
20+
// CHECK: [[EXECUTOR:%[^,]+]] = enum $Optional<Builtin.Executor>, #Optional.none!enumelt
21+
// CHECK: [[CALLEE:%[^,]+]] = function_ref @async_callee
22+
// CHECK: apply [[CALLEE]]()
23+
// CHECK: hop_to_executor [[EXECUTOR]]
24+
// CHECK: destroy_value [[MOVE]]
25+
// CHECK-LABEL: } // end sil function 'async_dead_arg_call_lexical'
26+
@_silgen_name("async_dead_arg_call_lexical")
27+
public func async_dead_arg_call_lexical(@_noEagerMove o: consuming AnyObject) async {
28+
await bar()
29+
// o should be destroyed here
30+
}
31+
32+
extension C {
33+
// CHECK-LABEL: sil [ossa] @async_dead_arg_call_lexical_method : {{.*}} {
34+
// CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : @_lexical @owned
35+
// CHECK-LABEL: } // end sil function 'async_dead_arg_call_lexical_method'
36+
@_silgen_name("async_dead_arg_call_lexical_method")
37+
@_noEagerMove
38+
consuming
39+
public func async_dead_arg_call_lexical_method() async {
40+
await bar()
41+
// self should be destroyed here
42+
}
43+
}
44+
1745
public class C {
1846
// CHECK-LABEL: sil [ossa] @async_dead_arg_call_method : {{.*}} {
1947
// CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : @_eagerMove @owned

0 commit comments

Comments
 (0)