@@ -35,15 +35,18 @@ bb0(%0 : @guaranteed $Builtin.NativeObject):
35
35
// CHECK-LABEL: define hidden swiftcc void @launch_task
36
36
sil hidden [ossa] @launch_task : $@convention(method) @async (Int, Optional<Builtin.NativeObject>, @guaranteed @async @callee_guaranteed () -> (@error Error)) -> () {
37
37
bb0(%0 : $Int, %1: @unowned $Optional<Builtin.NativeObject>, %2: @guaranteed $@async @callee_guaranteed () -> (@error Error)):
38
- %3 = begin_borrow %1 : $Optional<Builtin.NativeObject>
39
- // CHECK: call %swift.refcounted* @swift_retain(%swift.refcounted* returned [[FN_CONTEXT:%.*]])
38
+ %copy = copy_value %1 : $Optional<Builtin.NativeObject>
39
+ %3 = begin_borrow %copy : $Optional<Builtin.NativeObject>
40
+ // CHECK: [[FN_CONTEXT:%.*]] = load %swift.refcounted*, %swift.refcounted** %.data
41
+ // CHECK: call %swift.refcounted* @swift_retain(%swift.refcounted* returned [[FN_CONTEXT]])
40
42
// CHECK: [[NEW_TASK_AND_CONTEXT:%.*]] = call swiftcc %swift.async_task_and_context @swift_task_create_f(
41
43
// CHECK-NEXT: [[NEW_CONTEXT_RAW:%.*]] = extractvalue %swift.async_task_and_context [[NEW_TASK_AND_CONTEXT]], 1
42
44
// CHECK-NEXT: [[NEW_CONTEXT:%.*]] = bitcast %swift.context* [[NEW_CONTEXT_RAW]] to
43
45
// CHECK-NEXT: [[CONTEXT_INFO_LOC:%.*]] = getelementptr inbounds <{{.*}}>* [[NEW_CONTEXT]]
44
46
// CHECK-NEXT: store %swift.refcounted* [[FN_CONTEXT]], %swift.refcounted** [[CONTEXT_INFO_LOC]]
45
47
%20 = builtin "createAsyncTask"(%0 : $Int, %3 : $Optional<Builtin.NativeObject>, %2 : $@async @callee_guaranteed () -> (@error Error)) : $(Builtin.NativeObject, Builtin.RawPointer)
46
48
end_borrow %3 : $Optional<Builtin.NativeObject>
49
+ destroy_value %copy : $Optional<Builtin.NativeObject>
47
50
destroy_value %20 : $(Builtin.NativeObject, Builtin.RawPointer)
48
51
%21 = tuple ()
49
52
return %21 : $()
@@ -52,7 +55,11 @@ bb0(%0 : $Int, %1: @unowned $Optional<Builtin.NativeObject>, %2: @guaranteed $@a
52
55
// CHECK-LABEL: define hidden swiftcc void @launch_future
53
56
sil hidden [ossa] @launch_future : $@convention(method) <T> (Int, Optional<Builtin.NativeObject>, @guaranteed @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <T>, @in_guaranteed T) -> () {
54
57
bb0(%0 : $Int, %1: @unowned $Optional<Builtin.NativeObject>, %2: @guaranteed $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <T>, %3: $*T):
55
- %4 = begin_borrow %1 : $Optional<Builtin.NativeObject>
58
+ %copy = copy_value %1 : $Optional<Builtin.NativeObject>
59
+ // CHECK-32: [[TEMP:%.*]] = inttoptr i32 %1 to %swift.refcounted*
60
+ // CHECK-64: [[TEMP:%.*]] = inttoptr i64 %1 to %swift.refcounted*
61
+ %4 = begin_borrow %copy : $Optional<Builtin.NativeObject>
62
+ // CHECK: call %swift.refcounted* @swift_retain(%swift.refcounted* returned [[TEMP]])
56
63
// CHECK: call %swift.refcounted* @swift_retain(%swift.refcounted* returned [[FN_CONTEXT:%.*]])
57
64
%9 = metatype $@thick T.Type
58
65
%10 = init_existential_metatype %9 : $@thick T.Type, $@thick Any.Type
@@ -64,14 +71,20 @@ bb0(%0 : $Int, %1: @unowned $Optional<Builtin.NativeObject>, %2: @guaranteed $@a
64
71
// CHECK-NEXT: store %swift.refcounted* [[FN_CONTEXT]], %swift.refcounted** [[CONTEXT_INFO_LOC]]
65
72
%20 = builtin "createAsyncTaskFuture"<T>(%0 : $Int, %4 : $Optional<Builtin.NativeObject>, %10 : $@thick Any.Type, %2 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <T>) : $(Builtin.NativeObject, Builtin.RawPointer)
66
73
end_borrow %4 : $Optional<Builtin.NativeObject>
74
+ destroy_value %copy : $Optional<Builtin.NativeObject>
67
75
destroy_value %20 : $(Builtin.NativeObject, Builtin.RawPointer)
68
76
%21 = tuple ()
69
77
return %21 : $()
70
78
}
71
79
80
+ // CHECK-LABEL: define hidden swiftcc void @launch_void_future
72
81
sil hidden [ossa] @launch_void_future : $@convention(method) (Int, Optional<Builtin.NativeObject>, @guaranteed @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <()>) -> () {
73
82
bb0(%0 : $Int, %1: @unowned $Optional<Builtin.NativeObject>, %2: @guaranteed $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <()>):
74
- %4 = begin_borrow %1 : $Optional<Builtin.NativeObject>
83
+ %copy = copy_value %1 : $Optional<Builtin.NativeObject>
84
+ %4 = begin_borrow %copy : $Optional<Builtin.NativeObject>
85
+ // CHECK-32: [[TEMP:%.*]] = inttoptr i32 %1 to %swift.refcounted*
86
+ // CHECK-64: [[TEMP:%.*]] = inttoptr i64 %1 to %swift.refcounted*
87
+ // CHECK: call %swift.refcounted* @swift_retain(%swift.refcounted* returned [[TEMP]])
75
88
// CHECK: call %swift.refcounted* @swift_retain(%swift.refcounted* returned [[FN_CONTEXT:%.*]])
76
89
%8 = metatype $@thick ().Type // user: %9
77
90
%9 = init_existential_metatype %8 : $@thick ().Type, $@thick Any.Type // user: %10
@@ -83,6 +96,7 @@ bb0(%0 : $Int, %1: @unowned $Optional<Builtin.NativeObject>, %2: @guaranteed $@a
83
96
// CHECK-NEXT: store %swift.refcounted* [[FN_CONTEXT]], %swift.refcounted** [[CONTEXT_INFO_LOC]]
84
97
%20 = builtin "createAsyncTaskFuture"<()>(%0 : $Int, %4 : $Optional<Builtin.NativeObject>, %9 : $@thick Any.Type, %2 : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <()>) : $(Builtin.NativeObject, Builtin.RawPointer)
85
98
end_borrow %4 : $Optional<Builtin.NativeObject>
99
+ destroy_value %copy : $Optional<Builtin.NativeObject>
86
100
destroy_value %20 : $(Builtin.NativeObject, Builtin.RawPointer)
87
101
%21 = tuple ()
88
102
return %21 : $()
0 commit comments