Skip to content

Commit 24c62bc

Browse files
Merge pull request #66884 from aschwaighofer/fix_some_opaque_ptr_tests_04
Fix some opaque pointer LLVM IR tests (4)
2 parents 5c74365 + b182b14 commit 24c62bc

File tree

159 files changed

+4591
-7913
lines changed

Some content is hidden

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

159 files changed

+4591
-7913
lines changed

test/IRGen/actor_class_objc_backdeploy.swift

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
// RUN: %target-swift-frontend %use_no_opaque_pointers -emit-ir %s -swift-version 5 -target %target-cpu-apple-macosx11.0 -module-name actor_class_objc | %IRGenFileCheck %s
2-
// RUN: %target-swift-frontend -emit-ir %s -swift-version 5 -target %target-cpu-apple-macosx11.0 -module-name actor_class_objc
1+
// RUN: %target-swift-frontend -emit-ir %s -swift-version 5 -target %target-cpu-apple-macosx11.0 -module-name actor_class_objc | %IRGenFileCheck %s
32
// REQUIRES: concurrency
43
// REQUIRES: objc_interop
54
// REQUIRES: OS=macosx
65

76
import Foundation
87

98
// CHECK: %T16actor_class_objc7MyClassC = type <{ %swift.refcounted, %swift.defaultactor, %TSi }>
10-
// CHECK: %swift.defaultactor = type { [12 x i8*] }
9+
// CHECK: %swift.defaultactor = type { [12 x ptr] }
1110

1211
// CHECK-LABEL: @"OBJC_METACLASS_$__TtC16actor_class_objc7MyClass" = global
1312
// Metaclass is an instance of the root class.
14-
// CHECK-SAME: %objc_class* {{.*}}@"OBJC_METACLASS_$_NSObject{{(.ptrauth)?}}"
13+
// CHECK-SAME: ptr {{.*}}@"OBJC_METACLASS_$_NSObject{{(.ptrauth)?}}"
1514

1615
// CHECK: @"$s16actor_class_objc7MyClassCMf" = internal global
1716
// CHECK-SAME: @"$s16actor_class_objc7MyClassCfD{{(.ptrauth)?}}"
@@ -41,20 +40,19 @@ import Foundation
4140

4241

4342
// CHECK-LABEL: define {{.*}} @"$s16actor_class_objc7MyClassC1xSivg"
44-
// CHECK: [[T0:%.*]] = getelementptr inbounds %T16actor_class_objc7MyClassC, %T16actor_class_objc7MyClassC* %0, i32 0, i32 2
45-
// CHECK: [[T1:%.*]] = getelementptr inbounds %TSi, %TSi* [[T0]], i32 0, i32 0
46-
// CHECK: load [[INT]], [[INT]]* [[T1]], align
43+
// CHECK: [[T0:%.*]] = getelementptr inbounds %T16actor_class_objc7MyClassC, ptr %0, i32 0, i32 2
44+
// CHECK: [[T1:%.*]] = getelementptr inbounds %TSi, ptr [[T0]], i32 0, i32 0
45+
// CHECK: load [[INT]], ptr [[T1]], align
4746

48-
// CHECK-LABEL: define {{.*}}swiftcc %T16actor_class_objc7MyClassC* @"$s16actor_class_objc7MyClassCACycfc"
47+
// CHECK-LABEL: define {{.*}}swiftcc ptr @"$s16actor_class_objc7MyClassCACycfc"
4948
// CHECK: swift_defaultActor_initialize
50-
// CHECK-LABEL: ret %T16actor_class_objc7MyClassC*
49+
// CHECK-LABEL: ret ptr
5150

5251
// CHECK: swift_defaultActor_destroy
5352

5453
// CHECK-LABEL: define private void @_swift_objc_actor_initialization()
55-
// CHECK: [[SWIFT_NATIVE_NSOBJECT_CLASS:%.*]] = call %objc_class* @objc_getRequiredClass(i8* getelementptr inbounds ([20 x i8], [20 x i8]* [[SWIFT_NATIVE_NSOBJECT_NAME]]
54+
// CHECK: [[SWIFT_NATIVE_NSOBJECT_CLASS:%.*]] = call ptr @objc_getRequiredClass(ptr [[SWIFT_NATIVE_NSOBJECT_NAME]]
5655
// CHECK: [[ACTOR_RESPONSE:%.*]] = call swiftcc %swift.metadata_response @"$s16actor_class_objc7MyClassCMa"(
5756
// CHECK: [[ACTOR_METADATA:%.*]] = extractvalue %swift.metadata_response [[ACTOR_RESPONSE]], 0
58-
// CHECK: [[ACTOR_CLASS:%.*]] = bitcast %swift.type* [[ACTOR_METADATA]] to %objc_class*
59-
// CHECK: call %objc_class* @class_setSuperclass(%objc_class* [[ACTOR_CLASS]], %objc_class* [[SWIFT_NATIVE_NSOBJECT_CLASS]])
57+
// CHECK: call ptr @class_setSuperclass(ptr [[ACTOR_METADATA]], ptr [[SWIFT_NATIVE_NSOBJECT_CLASS]])
6058

test/IRGen/async/get_async_continuation.sil

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// RUN: %target-swift-frontend %use_no_opaque_pointers -g -enable-objc-interop -primary-file %s -emit-ir -sil-verify-all -disable-llvm-optzns -disable-swift-specific-llvm-optzns | %IRGenFileCheck %s
2-
// RUN: %target-swift-frontend -g -enable-objc-interop -primary-file %s -emit-ir -sil-verify-all -disable-llvm-optzns -disable-swift-specific-llvm-optzns
1+
// RUN: %target-swift-frontend -g -enable-objc-interop -primary-file %s -emit-ir -sil-verify-all -disable-llvm-optzns -disable-swift-specific-llvm-optzns | %IRGenFileCheck %s
32
// RUN: %target-swift-frontend -enable-objc-interop -primary-file %s -emit-ir -sil-verify-all
43

54
// REQUIRES: concurrency
@@ -15,67 +14,64 @@ bb0:
1514
}
1615

1716
// CHECK-LABEL: define{{.*}} @async_continuation(
18-
// CHECK: [[ctxt_addr:%.*]] = alloca %swift.context*
17+
// CHECK: [[ctxt_addr:%.*]] = alloca ptr
1918
// CHECK: [[cont_context:%.*]] = alloca %swift.continuation_context
2019
// CHECK: [[result_storage:%.*]] = alloca i32
2120
// CHECK: call token @llvm.coro.id.async
22-
// CHECK: call i8* @llvm.coro.begin(
21+
// CHECK: call ptr @llvm.coro.begin(
2322

2423
// Initialize the async continuation context:
2524

2625
// Initialize Parent.
27-
// CHECK: [[base_context:%.*]] = getelementptr inbounds %swift.continuation_context, %swift.continuation_context* [[cont_context]], i32 0, i32 0
28-
// CHECK: [[context_addr:%.*]] = getelementptr inbounds %swift.context, %swift.context* [[base_context]], i32 0, i32 0
29-
// CHECK: [[ctxt:%.*]] = load %swift.context*, %swift.context** [[ctxt_addr]]
30-
// CHECK-arm64e: [[ctxt_addr_int:%[0-9]+]] = ptrtoint %swift.context** [[context_addr]] to i64
26+
// CHECK: [[base_context:%.*]] = getelementptr inbounds %swift.continuation_context, ptr [[cont_context]], i32 0, i32 0
27+
// CHECK: [[context_addr:%.*]] = getelementptr inbounds %swift.context, ptr [[base_context]], i32 0, i32 0
28+
// CHECK: [[ctxt:%.*]] = load ptr, ptr [[ctxt_addr]]
29+
// CHECK-arm64e: [[ctxt_addr_int:%[0-9]+]] = ptrtoint ptr [[context_addr]] to i64
3130
// CHECK-arm64e: [[ptrauth_blend:%[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 [[ctxt_addr_int]], i64 48546)
32-
// CHECK-arm64e: [[ctxt_int:%[0-9]+]] = ptrtoint %swift.context* [[ctxt]] to i64
31+
// CHECK-arm64e: [[ctxt_int:%[0-9]+]] = ptrtoint ptr [[ctxt]] to i64
3332
// CHECK-arm64e: [[signed_int:%[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 [[ctxt_int]], i32 2, i64 [[ptrauth_blend]])
34-
// CHECK-arm64e: [[signed_ctxt:%[0-9]+]] = inttoptr i64 [[signed_int]] to %swift.context*
35-
// CHECK-arm64e: store %swift.context* [[signed_ctxt]], %swift.context** [[context_addr]]
36-
// CHECK-x86_64: store %swift.context* [[ctxt]], %swift.context** [[context_addr]]
33+
// CHECK-arm64e: [[signed_ctxt:%[0-9]+]] = inttoptr i64 [[signed_int]] to ptr
34+
// CHECK-arm64e: store ptr [[signed_ctxt]], ptr [[context_addr]]
35+
// CHECK-x86_64: store ptr [[ctxt]], ptr [[context_addr]]
3736

3837
// Initialize NormalResult.
39-
// CHECK: [[result_addr:%.*]] = getelementptr inbounds %swift.continuation_context, %swift.continuation_context* [[cont_context]], i32 0, i32 4
40-
// CHECK: [[result_storage_as_opaque:%.*]] = bitcast i32* [[result_storage]] to %swift.opaque*
41-
// CHECK: store %swift.opaque* [[result_storage_as_opaque]], %swift.opaque** [[result_addr]]
38+
// CHECK: [[result_addr:%.*]] = getelementptr inbounds %swift.continuation_context, ptr [[cont_context]], i32 0, i32 4
39+
// CHECK: store ptr [[result_storage]], ptr [[result_addr]]
4240

4341
// Initialize ResumeParent.
44-
// CHECK: [[resume_intrinsic:%.*]] = call i8* @llvm.coro.async.resume()
45-
// CHECK: [[continuation_fn_addr:%.*]] = getelementptr inbounds %swift.context, %swift.context* [[base_context]], i32 0, i32 1
46-
// CHECK: [[continuation_fn:%.*]] = bitcast i8* [[resume_intrinsic]] to void (%swift.context*)*
47-
// CHECK-arm64e: [[continuation_fn_addr_int:%[0-9]+]] = ptrtoint void (%swift.context*)** [[continuation_fn_addr]] to i64
42+
// CHECK: [[resume_intrinsic:%.*]] = call ptr @llvm.coro.async.resume()
43+
// CHECK: [[continuation_fn_addr:%.*]] = getelementptr inbounds %swift.context, ptr [[base_context]], i32 0, i32 1
44+
// CHECK-arm64e: [[continuation_fn_addr_int:%[0-9]+]] = ptrtoint ptr [[continuation_fn_addr]] to i64
4845
// CHECK-arm64e: [[ptrauth_blend:%[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 [[continuation_fn_addr_int]], i64 55047)
49-
// CHECK-arm64e: [[continuation_fn_int:%[0-9]+]] = ptrtoint void (%swift.context*)* [[continuation_fn]] to i64
46+
// CHECK-arm64e: [[continuation_fn_int:%[0-9]+]] = ptrtoint ptr [[resume_intrinsic]] to i64
5047
// CHECK-arm64e: [[signed_int:%[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 [[continuation_fn_int]], i32 0, i64 [[ptrauth_blend]])
51-
// CHECK-arm64e: [[signed_continuation_fn:%[0-9]+]] = inttoptr i64 [[signed_int]] to void (%swift.context*)*
52-
// CHECK-arm64e: store void (%swift.context*)* [[signed_continuation_fn]], void (%swift.context*)** [[continuation_fn_addr]]
53-
// CHECK-x86_64: store void (%swift.context*)* [[continuation_fn]], void (%swift.context*)** [[continuation_fn_addr]]
48+
// CHECK-arm64e: [[signed_continuation_fn:%[0-9]+]] = inttoptr i64 [[signed_int]] to ptr
49+
// CHECK-arm64e: store ptr [[signed_continuation_fn]], ptr [[continuation_fn_addr]]
50+
// CHECK-x86_64: store ptr [[resume_intrinsic]], ptr [[continuation_fn_addr]]
5451

5552
// Call the runtime to retrieve and initialize the continuation.
56-
// CHECK: call swiftcc %swift.task* @swift_continuation_init(%swift.continuation_context* [[cont_context]], [[INT]] 0)
53+
// CHECK: call swiftcc ptr @swift_continuation_init(ptr [[cont_context]], [[INT]] 0)
5754

5855
// Do some stuff.
5956
// CHECK: call swiftcc void @not_async_test()
6057

6158
// Arrive at the await_async_continuation point.
62-
// CHECK: [[suspend:%.*]] = call { i8* } (i32, i8*, i8*, ...) @llvm.coro.suspend.async.sl_p0i8s(i32 0, i8* [[resume_intrinsic]], i8* bitcast (i8* (i8*)* @__swift_async_resume_project_context to i8*), i8* bitcast (void (%swift.continuation_context*)* @__swift_continuation_await_point to i8*), %swift.continuation_context* [[cont_context]])
63-
// CHECK: [[result_addr_addr:%.*]] = getelementptr inbounds %swift.continuation_context, %swift.continuation_context* [[cont_context]], i32 0, i32 4
64-
// CHECK: [[result_addr:%.*]] = load %swift.opaque*, %swift.opaque** [[result_addr_addr]]
65-
// CHECK: [[typed_result_addr:%.*]] = bitcast %swift.opaque* [[result_addr]] to i32*
66-
// CHECK: [[result_value:%.*]] = load i32, i32* [[typed_result_addr]]
59+
// CHECK: [[suspend:%.*]] = call { ptr } (i32, ptr, ptr, ...) @llvm.coro.suspend.async.sl_p0s(i32 0, ptr [[resume_intrinsic]], ptr @__swift_async_resume_project_context, ptr @__swift_continuation_await_point, ptr [[cont_context]])
60+
// CHECK: [[result_addr_addr:%.*]] = getelementptr inbounds %swift.continuation_context, ptr [[cont_context]], i32 0, i32 4
61+
// CHECK: [[result_addr:%.*]] = load ptr, ptr [[result_addr_addr]]
62+
// CHECK: [[result_value:%.*]] = load i32, ptr [[result_addr]]
6763
// CHECK: br label %[[result_bb:[0-9]+]]
6864

6965
// CHECK: [[result_bb]]:
7066
// CHECK: phi i32 [ [[result_value]], %entry ]
7167

72-
// CHECK: define {{.*}} void @__swift_continuation_await_point(%swift.continuation_context* %0)
73-
// CHECK: {{musttail call swifttailcc|tail call swiftcc}} void @swift_continuation_await(%swift.continuation_context* %0)
68+
// CHECK: define {{.*}} void @__swift_continuation_await_point(ptr %0)
69+
// CHECK: {{musttail call swifttailcc|tail call swiftcc}} void @swift_continuation_await(ptr %0)
7470
// CHECK-NEXT: ret void
7571

76-
// CHECK: define {{.*}} void @async_continuation.0(i8* %0, %swift.context* %1){{.*}}!dbg ![[DBG:[0-9]+]]
72+
// CHECK: define {{.*}} void @async_continuation.0(ptr %0, ptr %1){{.*}}!dbg ![[DBG:[0-9]+]]
7773
// CHECK-NOT: define
78-
// CHECK: tail call swift{{(tail)?}}cc void %{{.*}}(%swift.context* swiftasync %1)
74+
// CHECK: tail call swift{{(tail)?}}cc void %{{.*}}(ptr swiftasync %1)
7975
// CHECK-NEXT: ret void
8076
// CHECK: ![[DBG]] = distinct !DISubprogram(linkageName: "async_continuation"
8177

test/IRGen/async/hop_to_executor.sil

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// RUN: %target-swift-frontend %use_no_opaque_pointers -primary-file %s -module-name=test -disable-llvm-optzns -disable-swift-specific-llvm-optzns -emit-ir -sil-verify-all | %IRGenFileCheck %s -check-prefix CHECK-%target-abi
2-
// RUN: %target-swift-frontend -primary-file %s -module-name=test -disable-llvm-optzns -disable-swift-specific-llvm-optzns -emit-ir -sil-verify-all
1+
// RUN: %target-swift-frontend -primary-file %s -module-name=test -disable-llvm-optzns -disable-swift-specific-llvm-optzns -emit-ir -sil-verify-all | %IRGenFileCheck %s -check-prefix CHECK-%target-abi
32

43
// REQUIRES: concurrency
54

@@ -14,13 +13,19 @@ import Swift
1413
import _Concurrency
1514

1615
// CHECK-LABEL: define{{.*}} void @test_simple(
17-
// CHECK-SAME: %swift.context* swiftasync %0, [[INT]] %1, [[INT]] %2)
18-
// CHECK-DAG: [[CTX:%[0-9]+]] = bitcast %swift.context* %0
19-
// CHECK-DAG: [[RESUME:%[0-9]+]] = call i8* @llvm.coro.async.resume()
20-
// CHECK-x86_64: call {{.*}} @llvm.coro.suspend.async{{.*}}(i32 0, i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, [[INT]], [[INT]], %swift.context*)* @test_simple.1 to i8*), i8* [[RESUME]], [[INT]] %1, [[INT]] %2, %swift.context* {{%[0-9]+}})
21-
// CHECK-arm64e: call {{.*}} @llvm.coro.suspend.async{{.*}}(i32 0, i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, [[INT]], [[INT]], %swift.context*)* @test_simple.1 to i8*), i8* [[RESUME]], [[INT]] %1, [[INT]] %2, %swift.context* {{%[0-9]+}})
22-
// CHECK: [[RET_CONTINUATION:%.*]] = bitcast void (%swift.context*)* {{.*}} to i8*
23-
// CHECK: call i1 (i8*, i1, ...) @llvm.coro.end.async(i8* {{.*}}, i1 false, void (i8*, %swift.context*)* @[[TAIL_CALL_FUNC:.*]], i8* [[RET_CONTINUATION]]
16+
// CHECK-SAME: ptr swiftasync %0, [[INT]] %1, [[INT]] %2)
17+
// CHECK: store ptr %0, ptr [[CTX_ADDR:%[0-9]+]]
18+
// CHECK: [[RESUME:%[0-9]+]] = call ptr @llvm.coro.async.resume()
19+
// CHECK: call {{.*}} @llvm.coro.suspend.async{{.*}}(i32 0, ptr [[RESUME]], ptr @__swift_async_resume_get_context, ptr @test_simple.1, ptr [[RESUME]], [[INT]] %1, [[INT]] %2, ptr {{%[0-9]+}})
20+
// CHECK: [[RESUME_CTX:%[0-9]+]] = call ptr @__swift_async_resume_get_context(
21+
// CHECK: store ptr [[RESUME_CTX]], ptr [[CTX_ADDR]]
22+
// CHECK: [[CTX:%[0-9+]+]] = load ptr, ptr [[CTX_ADDR]]
23+
// CHECK: [[CONT_ADDR:%[0-9]+]] = getelementptr inbounds <{ ptr, ptr }>, ptr [[CTX]], i32 0, i32 1
24+
// CHECK: [[RET_CONTINUATION:%.*]] = load ptr, ptr [[CONT_ADDR]]
25+
// CHECK-arm64e: [[T0:%.*]] = ptrtoint ptr [[RET_CONTINUATION]] to i64
26+
// CHECK-arm64e: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]
27+
// CHECK-arm64e: [[RET_CONTINUATION:%.*]] = inttoptr i64 [[T1]] to ptr
28+
// CHECK: call i1 (ptr, i1, ...) @llvm.coro.end.async(ptr {{.*}}, i1 false, ptr @[[TAIL_CALL_FUNC:.*]], ptr [[RET_CONTINUATION]]
2429
// CHECK: unreachable
2530

2631
sil @test_simple : $@async (@guaranteed Optional<Builtin.Executor>) -> () {
@@ -31,15 +36,14 @@ bb0(%0 : $Optional<Builtin.Executor>):
3136
}
3237

3338
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @test_simple.1
34-
// CHECK-SAME: (i8* [[RESUME_FN:%0]], [[INT]] %1, [[INT]] %2, %swift.context* [[CTXT:%[^,]+]])
35-
// CHECK-arm64e: [[RESUME_FN_INT:%[^,]+]] = ptrtoint i8* [[RESUME_FN]] to i64
39+
// CHECK-SAME: (ptr [[RESUME_FN:%0]], [[INT]] %1, [[INT]] %2, ptr [[CTXT:%[^,]+]])
40+
// CHECK-arm64e: [[RESUME_FN_INT:%[^,]+]] = ptrtoint ptr [[RESUME_FN]] to i64
3641
// CHECK-arm64e: [[PTRAUTH_SIGN:%[^,]+]] = call i64 @llvm.ptrauth.sign(i64 [[RESUME_FN_INT]], i32 0, i64 0)
37-
// CHECK-arm64e: [[RESUME_FN:%[^,]+]] = inttoptr i64 [[PTRAUTH_SIGN]] to i8*
38-
// CHECK: {{(must)?}}tail call swift{{(tail)?}}cc void @swift_task_switch(%swift.context* swiftasync [[CTXT]], i8* [[RESUME_FN]], [[INT]] %1, [[INT]] %2)
42+
// CHECK-arm64e: [[RESUME_FN:%[^,]+]] = inttoptr i64 [[PTRAUTH_SIGN]] to ptr
43+
// CHECK: {{(must)?}}tail call swift{{(tail)?}}cc void @swift_task_switch(ptr swiftasync [[CTXT]], ptr [[RESUME_FN]], [[INT]] %1, [[INT]] %2)
3944
// CHECK: ret void
4045

41-
// CHECK: define{{.*}} void @[[TAIL_CALL_FUNC]](i8* %0, %swift.context* %1)
42-
// CHECK: %2 = bitcast i8* %0 to void (%swift.context*)*
43-
// CHECK: {{(must)?}}tail call swift{{(tail)?}}cc void %2(%swift.context* swiftasync %1)
46+
// CHECK: define{{.*}} void @[[TAIL_CALL_FUNC]](ptr %0, ptr %1)
47+
// CHECK: {{(must)?}}tail call swift{{(tail)?}}cc void %0(ptr swiftasync %1)
4448
// CHECK: ret void
4549
// CHECK: }

0 commit comments

Comments
 (0)