Skip to content

Commit c8199b4

Browse files
committed
[concurrency] Use the previous commit to change an IR test to a LoweredSIL test case.
This just makes the test more cross platform since we do not have to look at differing codegen due to IRGen ABI level considerations. rdar://138845396
1 parent 4763251 commit c8199b4

File tree

1 file changed

+23
-35
lines changed

1 file changed

+23
-35
lines changed

test/Concurrency/hoptomainactorifneeded.swift

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-swift-frontend -swift-version 6 -enable-experimental-feature GenerateForceToMainActorThunks -import-objc-header %S/Inputs/hoptomainactorifneeded.h -emit-silgen %s | %FileCheck %s
2-
// RUN: %target-swift-frontend -swift-version 6 -enable-experimental-feature GenerateForceToMainActorThunks -import-objc-header %S/Inputs/hoptomainactorifneeded.h -emit-ir %s | %FileCheck -check-prefix=IR %s
2+
// RUN: %target-swift-frontend -swift-version 6 -enable-experimental-feature GenerateForceToMainActorThunks -import-objc-header %S/Inputs/hoptomainactorifneeded.h -emit-lowered-sil %s | %FileCheck -check-prefix=LOWERED %s
33

44
// READ THIS: This test validates that basic lowering of hop to main actor if
55
// needed works. For fuller tests that validate that things actually hop, see
@@ -26,40 +26,28 @@
2626

2727
// Check that we actually emit the thunk and call taskRunOnMainActor.
2828
//
29-
// IR-LABEL: define linkonce_odr hidden swiftcc void @"$s22hoptomainactorifneeded11testClosureyyYaFTTH"(ptr %0, ptr %1)
30-
// IR-NEXT: entry:
31-
// IR-NEXT: call swiftcc void @"$ss19_taskRunOnMainActor9operationyyyScMYcc_tF"(ptr %0, ptr %1)
32-
// IR-NEXT: ret void
33-
// IR-NEXT: }
34-
35-
// Test Closure. We just hop onto the main actor.
36-
// IR-LABEL: define hidden swifttailcc void @"$s22hoptomainactorifneeded11testClosureyyYaF"(ptr swiftasync %0)
37-
// IR: musttail call swifttailcc void @swift_task_switch(ptr swiftasync {{%.*}}, ptr @"$s22hoptomainactorifneeded11testClosureyyYaFTY0_",
38-
39-
// After we hop onto the main actor, we store the partial apply forwarder to the
40-
// hop to main actor closure.
41-
//
42-
// IR: define internal swifttailcc void @"$s22hoptomainactorifneeded11testClosureyyYaFTY0_"(ptr swiftasync [[ASYNC_CONTEXT:%.*]])
43-
// IR: %async.ctx.frameptr = getelementptr inbounds i8, ptr [[ASYNC_CONTEXT]], i32 16
44-
// IR: [[FUNC1:%.*]] = getelementptr inbounds %"$s22hoptomainactorifneeded11testClosureyyYaF.Frame", ptr %async.ctx.frameptr, i32 0, i32 0
45-
// IR: [[FUNC2:%.*]] = getelementptr inbounds { %objc_block, %swift.function }, ptr [[FUNC1]], i32 0, i32 1
46-
// IR: [[FUNC3:%.*]] = getelementptr inbounds %swift.function, ptr [[FUNC2]], i32 0, i32 0
47-
// IR: store ptr @"$s22hoptomainactorifneeded11testClosureyyYaFTTHTA", ptr [[FUNC3]]
48-
49-
// In the partial apply forwarder, we need to call the actual hop to main actor
50-
// thunk.
51-
//
52-
// IR: define internal swiftcc void @"$s22hoptomainactorifneeded11testClosureyyYaFTTHTA"(ptr swiftself [[FRAME:%.*]])
53-
// IR-NEXT: entry:
54-
// IR-NEXT: [[FRAME_GEP:%.*]] = getelementptr inbounds <{ %swift.refcounted, %swift.function }>, ptr [[FRAME]], i32 0, i32 1
55-
// IR-NEXT: [[FUNC2:%.*]] = getelementptr inbounds %swift.function, ptr [[FRAME_GEP]], i32 0, i32 0
56-
// IR-NEXT: [[FUNC2_LOADED:%.*]] = load ptr, ptr [[FUNC2]]
57-
// IR-NEXT: [[DATA:%.*]] = getelementptr inbounds %swift.function, ptr [[FRAME_GEP]]
58-
// IR-NEXT: [[DATA_LOADED:%.*]] = load ptr, ptr [[DATA]]
59-
// IR-NEXT: tail call swiftcc void @"$s22hoptomainactorifneeded11testClosureyyYaFTTH"(ptr [[FUNC2_LOADED]], ptr [[DATA_LOADED]])
60-
// IR-NEXT: ret void
61-
// IR-NEXT: }
62-
29+
// LOWERED-LABEL: sil shared [thunk] @$s22hoptomainactorifneeded11testClosureyyYaFTTH : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> () {
30+
// LOWERED: bb0([[ARG:%.*]] : $@callee_guaranteed () -> ()):
31+
// LOWERED: [[FUNC:%.*]] = function_ref @$ss19_taskRunOnMainActor9operationyyyScMYcc_tF : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
32+
// LOWERED: apply [[FUNC]]([[ARG]])
33+
// LOWERED: } // end sil function '$s22hoptomainactorifneeded11testClosureyyYaFTTH
34+
35+
// testClosure.
36+
// LOWERED-LABEL: sil hidden @$s22hoptomainactorifneeded11testClosureyyYaF : $@convention(thin) @async () -> () {
37+
// LOWERED: [[CLOSURE:%.*]] = function_ref @$s22hoptomainactorifneeded11testClosureyyYaFyyScMYccfU_ : $@convention(thin) () -> ()
38+
// LOWERED: [[THICK_CLOSURE:%.*]] = thin_to_thick_function [[CLOSURE]]
39+
// LOWERED: [[THUNK:%.*]] = function_ref @$s22hoptomainactorifneeded11testClosureyyYaFTTH : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
40+
// LOWERED: [[THUNKED_CLOSURE:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[THICK_CLOSURE]])
41+
// LOWERED: [[BLOCK_STORAGE:%.*]] = alloc_stack $@block_storage
42+
// LOWERED: [[PROJECT_BLOCK_STORAGE:%.*]] = project_block_storage [[BLOCK_STORAGE]]
43+
// LOWERED: store [[THUNKED_CLOSURE]] to [[PROJECT_BLOCK_STORAGE]]
44+
// LOWERED: [[THUNK_THUNK_CALLEE:%.*]] = function_ref @$sIeg_IeyB_TR : $@convention(c) (@inout_aliasable @block_storage @callee_guaranteed () -> ()) -> ()
45+
// LOWERED: [[BLOCK:%.*]] = init_block_storage_header [[BLOCK_STORAGE]] : $*@block_storage @callee_guaranteed () -> (), invoke [[THUNK_THUNK_CALLEE]]
46+
// LOWERED: [[FINISHED_BLOCK:%.*]] = copy_block [[BLOCK]]
47+
// LOWERED: [[OPT_BLOCK:%.*]] = enum $Optional<@convention(block) () -> ()>, #Optional.some!enumelt, [[FINISHED_BLOCK]]
48+
// LOWERED: [[USE_CLOSURE_CALLEE:%.*]] = function_ref @useClosure : $@convention(c) (Optional<@convention(block) () -> ()>) -> ()
49+
// LOWERED: apply [[USE_CLOSURE_CALLEE]]([[OPT_BLOCK]])
50+
// LOWERED: } // end sil function '$s22hoptomainactorifneeded11testClosureyyYaF'
6351
@MainActor
6452
func testClosure() async {
6553
useClosure {

0 commit comments

Comments
 (0)