Skip to content

Commit 2a05803

Browse files
Merge pull request #35724 from nate-chandler/concurrency/irgen/rdar72357371
[Test] Reenable most concurrency tests on arm64e.
2 parents f176ea9 + 53d8780 commit 2a05803

File tree

47 files changed

+503
-541
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+503
-541
lines changed

include/swift/ABI/MetadataValues.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ namespace SpecialPointerAuthDiscriminators {
11861186
const uint16_t EscalationNotificationFunction = 0x5be4; // = 23524
11871187

11881188
/// Swift async context parameter stored in the extended frame info.
1189-
const uint16_t SwiftAsyncContextExtendedFrameEntry = 0xc31a;
1189+
const uint16_t SwiftAsyncContextExtendedFrameEntry = 0xc31a; // = 49946
11901190
}
11911191

11921192
/// The number of arguments that will be passed directly to a generic

lib/IRGen/GenFunc.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,7 @@ llvm::Function *IRGenFunction::getOrCreateResumePrjFn() {
24012401
// TODO: remove this once all platforms support lowering the intrinsic.
24022402
// At the time of this writing only arm64 supports it.
24032403
if (IGM.TargetInfo.canUseSwiftAsyncContextAddrIntrinsic()) {
2404+
llvm::Value *storedCallerContext = callerContext;
24042405
auto contextLocationInExtendedFrame =
24052406
Address(Builder.CreateIntrinsicCall(
24062407
llvm::Intrinsic::swift_async_context_addr, {}),
@@ -2412,9 +2413,9 @@ llvm::Function *IRGenFunction::getOrCreateResumePrjFn() {
24122413
auto authInfo = PointerAuthInfo::emit(
24132414
IGF, schema, contextLocationInExtendedFrame.getAddress(),
24142415
PointerAuthEntity());
2415-
callerContext = emitPointerAuthSign(IGF, callerContext, authInfo);
2416+
storedCallerContext = emitPointerAuthSign(IGF, storedCallerContext, authInfo);
24162417
}
2417-
Builder.CreateStore(callerContext, contextLocationInExtendedFrame);
2418+
Builder.CreateStore(storedCallerContext, contextLocationInExtendedFrame);
24182419
}
24192420
Builder.CreateRet(callerContext);
24202421
},

test/Concurrency/Runtime/actor_counters.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
// Remove with rdar://problem/72439642
88
// UNSUPPORTED: asan
9+
// Remove with rdar://problem/72357371
10+
// UNSUPPORTED: CPU=arm64e
911

1012
#if canImport(Darwin)
1113
import Darwin

test/Concurrency/Runtime/mainactor.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
// REQUIRES: OS=macosx || OS=ios
77
// FIXME: should not require Darwin to run this test once we have async main!
8+
// Remove with rdar://problem/72357371
9+
// UNSUPPORTED: CPU=arm64e
810

911
// for exit(:Int)
1012
#if canImport(Darwin)

test/Concurrency/Runtime/objc_async.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// REQUIRES: concurrency
88
// REQUIRES: objc_interop
99

10+
// Remove with rdar://problem/72357371
11+
// UNSUPPORTED: CPU=arm64e
12+
1013

1114
@main struct Main {
1215
static func main() async {

test/IRGen/async/hop_to_executor.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final actor class MyActor {
2929
// CHECK-arm64e: [[SIGNED_RESUME:%[0-9]+]] = inttoptr i64 [[SIGNED_INT]] to i8*
3030
// CHECK: [[CAST_ACTOR:%[0-9]+]] = bitcast %T4test7MyActorC* [[ACTOR]] to %swift.executor*
3131
// CHECK-x86_64: call {{.*}} @llvm.coro.suspend.async(i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, %swift.executor*, %swift.task*, %swift.executor*, %swift.context*)* @__swift_suspend_point to i8*), i8* [[RESUME]], %swift.executor* [[CAST_ACTOR]], %swift.task* [[TASK]], %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}})
32-
// CHECK-arm64e: call {{.*}} @llvm.coro.suspend.async(i8* [[SIGNED_RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, %swift.executor*, %swift.task*, %swift.executor*, %swift.context*)* @__swift_suspend_point to i8*), i8* [[SIGNED_RESUME]], %swift.executor* [[CAST_ACTOR]], %swift.task* [[TASK]], %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}})
32+
// CHECK-arm64e: call {{.*}} @llvm.coro.suspend.async(i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, %swift.executor*, %swift.task*, %swift.executor*, %swift.context*)* @__swift_suspend_point to i8*), i8* [[SIGNED_RESUME]], %swift.executor* [[CAST_ACTOR]], %swift.task* [[TASK]], %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}})
3333
sil @test_simple : $@convention(method) @async (@guaranteed MyActor) -> () {
3434
bb0(%0 : $MyActor):
3535
hop_to_executor %0 : $MyActor

test/IRGen/async/run-call-classinstance-int64-to-void.sil

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ sil_vtable S {
8686
#S.deinit!deallocator: @S_deallocating_deinit
8787
}
8888

89-
// Defined in _Concurrency
90-
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
91-
9289
sil @test_case : $@convention(thin) @async () -> () {
9390
%s_type = metatype $@thick S.Type
9491
%allocating_init = function_ref @S_allocating_init : $@convention(method) (@thick S.Type) -> @owned S
@@ -104,15 +101,18 @@ sil @test_case : $@convention(thin) @async () -> () {
104101
return %void : $()
105102
}
106103

104+
// Defined in _Concurrency
105+
sil @$s12_Concurrency13_runAsyncMainyyyyYKcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
106+
107+
// main
107108
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
108109
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
109-
110-
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
111-
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
112-
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
113-
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
114-
115-
%6 = integer_literal $Builtin.Int32, 0
116-
%7 = struct $Int32 (%6 : $Builtin.Int32)
117-
return %7 : $Int32
110+
%test_case_nothrow = function_ref @test_case : $@convention(thin) @async () -> ()
111+
%test_case = convert_function %test_case_nothrow : $@convention(thin) @async () -> () to $@convention(thin) @async () -> @error Error
112+
%thick_test_case = thin_to_thick_function %test_case : $@convention(thin) @async () -> @error Error to $@callee_guaranteed @async () -> @error Error
113+
%runAsyncMain = function_ref @$s12_Concurrency13_runAsyncMainyyyyYKcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
114+
%result = apply %runAsyncMain(%thick_test_case) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
115+
%out_literal = integer_literal $Builtin.Int32, 0
116+
%out = struct $Int32 (%out_literal : $Builtin.Int32)
117+
return %out : $Int32
118118
}

test/IRGen/async/run-call-classinstance-void-to-void.sil

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ sil_vtable S {
8686
#S.deinit!deallocator: @S_deallocating_deinit
8787
}
8888

89-
// Defined in _Concurrency
90-
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
91-
9289
sil @test_case : $@convention(thin) @async () -> () {
9390
%s_type = metatype $@thick S.Type
9491
%allocating_init = function_ref @S_allocating_init : $@convention(method) (@thick S.Type) -> @owned S
@@ -102,15 +99,18 @@ sil @test_case : $@convention(thin) @async () -> () {
10299
return %void : $()
103100
}
104101

102+
// Defined in _Concurrency
103+
sil @$s12_Concurrency13_runAsyncMainyyyyYKcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
104+
105+
// main
105106
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
106107
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
107-
108-
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
109-
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
110-
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
111-
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
112-
113-
%6 = integer_literal $Builtin.Int32, 0
114-
%7 = struct $Int32 (%6 : $Builtin.Int32)
115-
return %7 : $Int32
108+
%test_case_nothrow = function_ref @test_case : $@convention(thin) @async () -> ()
109+
%test_case = convert_function %test_case_nothrow : $@convention(thin) @async () -> () to $@convention(thin) @async () -> @error Error
110+
%thick_test_case = thin_to_thick_function %test_case : $@convention(thin) @async () -> @error Error to $@callee_guaranteed @async () -> @error Error
111+
%runAsyncMain = function_ref @$s12_Concurrency13_runAsyncMainyyyyYKcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
112+
%result = apply %runAsyncMain(%thick_test_case) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
113+
%out_literal = integer_literal $Builtin.Int32, 0
114+
%out = struct $Int32 (%out_literal : $Builtin.Int32)
115+
return %out : $Int32
116116
}

test/IRGen/async/run-call-existential-to-void.sil

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ bb0:
6969
return %result : $()
7070
}
7171

72-
// Defined in _Concurrency
73-
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
74-
7572
sil @test_case : $@convention(thin) @async () -> () {
7673
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 7384783
7774
%result = apply %call() : $@async @convention(thin) () -> ()
@@ -80,15 +77,18 @@ sil @test_case : $@convention(thin) @async () -> () {
8077
return %void : $()
8178
}
8279

80+
// Defined in _Concurrency
81+
sil @$s12_Concurrency13_runAsyncMainyyyyYKcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
82+
83+
// main
8384
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
8485
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
85-
86-
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
87-
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
88-
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
89-
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
90-
91-
%6 = integer_literal $Builtin.Int32, 0
92-
%7 = struct $Int32 (%6 : $Builtin.Int32)
93-
return %7 : $Int32
86+
%test_case_nothrow = function_ref @test_case : $@convention(thin) @async () -> ()
87+
%test_case = convert_function %test_case_nothrow : $@convention(thin) @async () -> () to $@convention(thin) @async () -> @error Error
88+
%thick_test_case = thin_to_thick_function %test_case : $@convention(thin) @async () -> @error Error to $@callee_guaranteed @async () -> @error Error
89+
%runAsyncMain = function_ref @$s12_Concurrency13_runAsyncMainyyyyYKcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
90+
%result = apply %runAsyncMain(%thick_test_case) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
91+
%out_literal = integer_literal $Builtin.Int32, 0
92+
%out = struct $Int32 (%out_literal : $Builtin.Int32)
93+
return %out : $Int32
9494
}

test/IRGen/async/run-call-generic-to-generic.sil

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ bb0(%out : $*T, %in : $*T):
2828
return %result : $()
2929
}
3030

31-
// Defined in _Concurrency
32-
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
33-
3431
sil @test_case : $@convention(thin) @async () -> () {
3532
%int_literal = integer_literal $Builtin.Int64, 42
3633
%int = struct $Int64 (%int_literal : $Builtin.Int64)
@@ -52,15 +49,18 @@ sil @test_case : $@convention(thin) @async () -> () {
5249
return %void : $()
5350
}
5451

52+
// Defined in _Concurrency
53+
sil @$s12_Concurrency13_runAsyncMainyyyyYKcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
54+
55+
// main
5556
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
5657
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
57-
58-
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
59-
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
60-
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
61-
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
62-
63-
%6 = integer_literal $Builtin.Int32, 0
64-
%7 = struct $Int32 (%6 : $Builtin.Int32)
65-
return %7 : $Int32
58+
%test_case_nothrow = function_ref @test_case : $@convention(thin) @async () -> ()
59+
%test_case = convert_function %test_case_nothrow : $@convention(thin) @async () -> () to $@convention(thin) @async () -> @error Error
60+
%thick_test_case = thin_to_thick_function %test_case : $@convention(thin) @async () -> @error Error to $@callee_guaranteed @async () -> @error Error
61+
%runAsyncMain = function_ref @$s12_Concurrency13_runAsyncMainyyyyYKcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
62+
%result = apply %runAsyncMain(%thick_test_case) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
63+
%out_literal = integer_literal $Builtin.Int32, 0
64+
%out = struct $Int32 (%out_literal : $Builtin.Int32)
65+
return %out : $Int32
6666
}

test/IRGen/async/run-call-generic-to-void.sil

Lines changed: 0 additions & 57 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency %s -parse-as-library -module-name main -emit-ir | %FileCheck %s --check-prefix=CHECK-LL
3+
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency %s -parse-as-library -module-name main -o %t/main
4+
// RUN: %target-codesign %t/main
5+
// RUN: %target-run %t/main | %FileCheck %s
6+
7+
// REQUIRES: executable_test
8+
// REQUIRES: swift_test_mode_optimize_none
9+
// REQUIRES: concurrency
10+
// UNSUPPORTED: use_os_stdlib
11+
12+
import _Concurrency
13+
14+
// CHECK-LL: @genericToVoidTu =
15+
// CHECK-LL: define hidden swiftcc void @genericToVoid(%swift.task* {{%[0-9]+}}, %swift.executor* {{%[0-9]+}}, %swift.context* swiftasync {{%[0-9]+}}) {{#[0-9]*}} {
16+
@_silgen_name("genericToVoid")
17+
func genericToVoid<T>(_ t: T) async {
18+
print(t) // CHECK: 922337203685477580
19+
20+
}
21+
22+
@_silgen_name("test_case")
23+
func test_case() async {
24+
await genericToVoid(922337203685477580 as Int64)
25+
}
26+
27+
@main struct Main {
28+
static func main() async {
29+
await test_case()
30+
}
31+
}

test/IRGen/async/run-call-genericEquatable-x2-to-bool.sil

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ bb0(%0 : $*T, %1 : $*T):
2929
return %6 : $Bool
3030
}
3131

32-
// Defined in _Concurrency
33-
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
34-
3532
sil @test_case : $@convention(thin) @async () -> () {
3633
%int1_literal = integer_literal $Builtin.Int64, 42
3734
%int1 = struct $Int64 (%int1_literal : $Builtin.Int64)
@@ -60,15 +57,18 @@ sil @test_case : $@convention(thin) @async () -> () {
6057
return %void : $()
6158
}
6259

60+
// Defined in _Concurrency
61+
sil @$s12_Concurrency13_runAsyncMainyyyyYKcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
62+
63+
// main
6364
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
6465
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
65-
66-
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
67-
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
68-
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
69-
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
70-
71-
%6 = integer_literal $Builtin.Int32, 0
72-
%7 = struct $Int32 (%6 : $Builtin.Int32)
73-
return %7 : $Int32
66+
%test_case_nothrow = function_ref @test_case : $@convention(thin) @async () -> ()
67+
%test_case = convert_function %test_case_nothrow : $@convention(thin) @async () -> () to $@convention(thin) @async () -> @error Error
68+
%thick_test_case = thin_to_thick_function %test_case : $@convention(thin) @async () -> @error Error to $@callee_guaranteed @async () -> @error Error
69+
%runAsyncMain = function_ref @$s12_Concurrency13_runAsyncMainyyyyYKcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
70+
%result = apply %runAsyncMain(%thick_test_case) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
71+
%out_literal = integer_literal $Builtin.Int32, 0
72+
%out = struct $Int32 (%out_literal : $Builtin.Int32)
73+
return %out : $Int32
7474
}

0 commit comments

Comments
 (0)