Skip to content

Commit d9e93a5

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents c47946a + be1e8f6 commit d9e93a5

21 files changed

+161
-102
lines changed

test/Concurrency/Runtime/actor_counters.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch)
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch -parse-as-library)
22

33
// REQUIRES: executable_test
44
// REQUIRES: concurrency
@@ -81,6 +81,8 @@ func runTest(numCounters: Int, numWorkers: Int, numIterations: Int) async {
8181
print("DONE!")
8282
}
8383

84-
runAsyncAndBlock {
85-
await runTest(numCounters: 10, numWorkers: 100, numIterations: 1000)
84+
@main struct Main {
85+
static func main() async {
86+
await runTest(numCounters: 10, numWorkers: 100, numIterations: 1000)
87+
}
8688
}

test/Concurrency/Runtime/async_let_fibonacci.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch)
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch -parse-as-library)
22

33
// REQUIRES: executable_test
44
// REQUIRES: concurrency
@@ -48,6 +48,8 @@ func runFibonacci(_ n: Int) async {
4848
assert(result == fib(n))
4949
}
5050

51-
runAsyncAndBlock {
52-
await runFibonacci(10)
51+
@main struct Main {
52+
static func main() async {
53+
await runFibonacci(10)
54+
}
5355
}
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency) | %FileCheck %s
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency -parse-as-library) | %FileCheck %s
22
// REQUIRES: executable_test
33
// REQUIRES: concurrency
44

5-
func test_getPriority() {
6-
runAsyncAndBlock {
5+
@main struct Main {
6+
static func main() async {
77
let p = await Task.currentPriority()
88
// CHECK: priority: default
99
print("priority: \(p)")
1010
assert(p == Task.Priority.default)
1111
}
1212
}
13-
14-
test_getPriority()

test/Concurrency/Runtime/async_taskgroup_add_handle_completion.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency) | %FileCheck %s --dump-input=always
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency -parse-as-library) | %FileCheck %s --dump-input=always
22
// REQUIRES: executable_test
33
// REQUIRES: concurrency
44
// REQUIRES: OS=macosx
@@ -65,4 +65,8 @@ func test_sum_nextOnPending() async {
6565
assert(sum == 6, "Expected \(6) but got \(sum)")
6666
}
6767

68-
runAsyncAndBlock(test_sum_nextOnPending)
68+
@main struct Main {
69+
static func main() async {
70+
await test_sum_nextOnPending()
71+
}
72+
}

test/Concurrency/Runtime/async_taskgroup_is_empty.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency) | %FileCheck %s --dump-input always
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency -parse-as-library) | %FileCheck %s --dump-input always
22
// REQUIRES: executable_test
33
// REQUIRES: concurrency
44
// REQUIRES: OS=macosx
@@ -40,4 +40,8 @@ func test_taskGroup_isEmpty() async {
4040
}
4141
}
4242

43-
runAsyncAndBlock(test_taskGroup_isEmpty)
43+
@main struct Main {
44+
static func main() async {
45+
await test_taskGroup_isEmpty()
46+
}
47+
}

test/Concurrency/Runtime/async_taskgroup_next_not_invoked_cancelAll.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency) | %FileCheck %s --dump-input=always
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency -parse-as-library) | %FileCheck %s --dump-input=always
22
// REQUIRES: executable_test
33
// REQUIRES: concurrency
44
// REQUIRES: OS=macosx
@@ -43,4 +43,8 @@ func test_skipCallingNext_butInvokeCancelAll() async {
4343
assert(result == 0)
4444
}
4545

46-
runAsyncAndBlock(test_skipCallingNext_butInvokeCancelAll)
46+
@main struct Main {
47+
static func main() async {
48+
await test_skipCallingNext_butInvokeCancelAll()
49+
}
50+
}

test/Concurrency/Runtime/async_taskgroup_next_not_invoked_without_cancelAll.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency) | %FileCheck %s --dump-input=always
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency -parse-as-library) | %FileCheck %s --dump-input=always
22
// REQUIRES: executable_test
33
// REQUIRES: concurrency
44
// REQUIRES: OS=macosx
@@ -36,5 +36,9 @@ func test_skipCallingNext() async {
3636
assert(result == 0)
3737
}
3838

39-
runAsyncAndBlock(test_skipCallingNext)
39+
@main struct Main {
40+
static func main() async {
41+
await test_skipCallingNext()
42+
}
43+
}
4044

test/Concurrency/Runtime/async_taskgroup_next_on_completed.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency) | %FileCheck %s --dump-input=always
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency -parse-as-library) | %FileCheck %s --dump-input=always
22
// REQUIRES: executable_test
33
// REQUIRES: concurrency
44
// REQUIRES: OS=macosx
@@ -71,4 +71,8 @@ func test_sum_nextOnCompleted() async {
7171
print("result: \(sum)")
7272
}
7373

74-
runAsyncAndBlock(test_sum_nextOnCompleted)
74+
@main struct Main {
75+
static func main() async {
76+
await test_sum_nextOnCompleted()
77+
}
78+
}

test/Concurrency/Runtime/async_taskgroup_next_on_pending.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency) | %FileCheck %s --dump-input=always
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency -parse-as-library) | %FileCheck %s --dump-input=always
22
// REQUIRES: executable_test
33
// REQUIRES: concurrency
44
// REQUIRES: OS=macosx
@@ -58,4 +58,8 @@ func test_sum_nextOnPending() async {
5858
assert(sum == expected, "Expected: \(expected), got: \(sum)")
5959
}
6060

61-
runAsyncAndBlock(test_sum_nextOnPending)
61+
@main struct Main {
62+
static func main() async {
63+
await test_sum_nextOnPending()
64+
}
65+
}

test/Concurrency/Runtime/async_taskgroup_throw_recover.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency) | %FileCheck %s --dump-input always
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency -parse-as-library) | %FileCheck %s --dump-input always
22
// REQUIRES: executable_test
33
// REQUIRES: concurrency
44
// REQUIRES: OS=macosx
@@ -83,4 +83,9 @@ func test_taskGroup_throws() async {
8383
}
8484
}
8585

86-
runAsyncAndBlock(test_taskGroup_throws)
86+
87+
@main struct Main {
88+
static func main() async {
89+
await test_taskGroup_throws()
90+
}
91+
}

test/Concurrency/Runtime/async_taskgroup_throw_rethrow.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency) | %FileCheck %s --dump-input always
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency -parse-as-library) | %FileCheck %s --dump-input always
22
// REQUIRES: executable_test
33
// REQUIRES: concurrency
44
// REQUIRES: OS=macosx
@@ -43,4 +43,8 @@ func test_taskGroup_throws_rethrows() async {
4343

4444
// CHECK: error caught and rethrown in group: Boom()
4545
// CHECK: rethrown: Boom()
46-
runAsyncAndBlock(test_taskGroup_throws_rethrows)
46+
@main struct Main {
47+
static func main() async {
48+
await test_taskGroup_throws_rethrows()
49+
}
50+
}

test/Concurrency/Runtime/basic_future.swift

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch)
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch -parse-as-library)
22

33
// REQUIRES: executable_test
44
// REQUIRES: concurrency
@@ -22,7 +22,7 @@ func formGreeting(name: String) async -> String {
2222

2323
func testSimple(
2424
name: String, dogName: String, shouldThrow: Bool, doSuspend: Bool
25-
) {
25+
) async {
2626
print("Testing name: \(name), dog: \(dogName), shouldThrow: \(shouldThrow) doSuspend: \(doSuspend)")
2727

2828
var completed = false
@@ -46,36 +46,39 @@ func testSimple(
4646
return greeting + "!"
4747
}
4848

49-
runAsyncAndBlock {
50-
// If the intent is not to test suspending, wait a bit so the first task
51-
// can complete.
52-
if !doSuspend {
53-
print("+ Reader sleeping")
54-
sleep(1)
55-
}
49+
// If the intent is not to test suspending, wait a bit so the first task
50+
// can complete.
51+
if !doSuspend {
52+
print("+ Reader sleeping")
53+
sleep(1)
54+
}
5655

57-
do {
58-
print("+ Reader waiting for the result")
59-
let result = try await taskHandle.get()
60-
completed = true
61-
print("+ Normal return: \(result)")
62-
assert(result == "Hello \(name) from async world!")
63-
} catch HomeworkError.dogAteIt(let badDog) {
64-
completed = true
65-
print("+ Error return: HomeworkError.dogAteIt(\(badDog))")
66-
assert(badDog == dogName + " the dog")
67-
} catch {
68-
fatalError("Caught a different exception?")
69-
}
56+
do {
57+
print("+ Reader waiting for the result")
58+
let result = try await taskHandle.get()
59+
completed = true
60+
print("+ Normal return: \(result)")
61+
assert(result == "Hello \(name) from async world!")
62+
} catch HomeworkError.dogAteIt(let badDog) {
63+
completed = true
64+
print("+ Error return: HomeworkError.dogAteIt(\(badDog))")
65+
assert(badDog == dogName + " the dog")
66+
} catch {
67+
fatalError("Caught a different exception?")
7068
}
7169

7270
assert(completed)
7371
print("Finished test")
7472
}
7573

76-
testSimple(name: "Ted", dogName: "Hazel", shouldThrow: false, doSuspend: false)
77-
testSimple(name: "Ted", dogName: "Hazel", shouldThrow: true, doSuspend: false)
78-
testSimple(name: "Ted", dogName: "Hazel", shouldThrow: false, doSuspend: true)
79-
testSimple(name: "Ted", dogName: "Hazel", shouldThrow: true, doSuspend: true)
8074

81-
print("Done")
75+
@main struct Main {
76+
static func main() async {
77+
await testSimple(name: "Ted", dogName: "Hazel", shouldThrow: false, doSuspend: false)
78+
await testSimple(name: "Ted", dogName: "Hazel", shouldThrow: true, doSuspend: false)
79+
await testSimple(name: "Ted", dogName: "Hazel", shouldThrow: false, doSuspend: true)
80+
await testSimple(name: "Ted", dogName: "Hazel", shouldThrow: true, doSuspend: true)
81+
82+
print("Done")
83+
}
84+
}

test/Concurrency/Runtime/future_fibonacci.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch)
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch -parse-as-library)
22

33
// REQUIRES: executable_test
44
// REQUIRES: concurrency
@@ -47,15 +47,16 @@ func asyncFib(_ n: Int) async -> Int {
4747
return result
4848
}
4949

50-
func runFibonacci(_ n: Int) {
51-
var result = 0
52-
runAsyncAndBlock {
53-
result = await asyncFib(n)
54-
}
50+
func runFibonacci(_ n: Int) async {
51+
var result = await asyncFib(n)
5552

5653
print()
5754
print("Async fib = \(result), sequential fib = \(fib(n))")
5855
assert(result == fib(n))
5956
}
6057

61-
runFibonacci(15)
58+
@main struct Main {
59+
static func main() async {
60+
await runFibonacci(15)
61+
}
62+
}

test/Concurrency/Runtime/objc_async.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-clang %S/Inputs/objc_async.m -c -o %t/objc_async_objc.o
3-
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -import-objc-header %S/Inputs/objc_async.h %s %t/objc_async_objc.o -o %t/objc_async
3+
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-as-library -module-name main -import-objc-header %S/Inputs/objc_async.h %s %t/objc_async_objc.o -o %t/objc_async
44
// RUN: %target-run %t/objc_async | %FileCheck %s
55

66
// REQUIRES: executable_test
77
// REQUIRES: concurrency
88
// REQUIRES: objc_interop
99

10-
runAsyncAndBlock {
10+
11+
@main struct Main {
12+
static func main() async {
1113
let butt = Butt()
1214
let result = await butt.butt(1738)
1315
print("finishing \(result)")
16+
}
1417
}
1518

1619
// CHECK: starting 1738

test/DebugInfo/async-args.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %target-swift-frontend %s -emit-ir -g -o - \
2-
// RUN: -module-name M -enable-experimental-concurrency | %FileCheck %s
2+
// RUN: -module-name M -enable-experimental-concurrency \
3+
// RUN: -parse-as-library | %FileCheck %s
34
// REQUIRES: concurrency
45

56
func use<T>(_ t: T) {}
@@ -32,8 +33,10 @@ func withGenericArg<T>(_ msg: T) async {
3233
use(msg)
3334
}
3435
// CHECK-LABEL: {{^define }}
35-
runAsyncAndBlock {
36-
await withGenericArg("hello (asynchronously)")
36+
@main struct Main {
37+
static func main() async {
38+
await withGenericArg("hello (asynchronously)")
39+
}
3740
}
3841
// CHECK: ![[TAU]] = !DILocalVariable(name: "$\CF\84_0_0",
3942
// CHECK: ![[MSG]] = !DILocalVariable(name: "msg", arg: 1,

test/IRGen/async/run-call-class-witnessmethod-void-to-void.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency %s -emit-ir | %FileCheck %s --check-prefix=CHECK-LL
3-
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency %s -module-name main -o %t/main
2+
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency %s -parse-as-library -emit-ir -module-name main | %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
44
// RUN: %target-codesign %t/main
55
// RUN: %target-run %t/main | %FileCheck %s
66

@@ -52,7 +52,9 @@ func call_f<T : P>(_ t: T) async {
5252

5353
class X {}
5454

55-
runAsyncAndBlock {
56-
let x = X()
57-
await call_f(x)
55+
@main struct Main {
56+
static func main() async {
57+
let x = X()
58+
await call_f(x)
59+
}
5860
}

test/IRGen/async/run-call-dynamic-void_to_void.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency %s -emit-ir | %FileCheck %s --check-prefix=CHECK-LL
3-
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency %s -module-name main -o %t/main %target-rpath(%t)
2+
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency %s -emit-ir -parse-as-library -module-name main | %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 %target-rpath(%t)
44
// RUN: %target-codesign %t/main
55
// RUN: %target-run %t/main | %FileCheck %s
66

@@ -14,13 +14,15 @@ import _Concurrency
1414

1515
// CHECK: running
1616

17-
// CHECK-LL: @"$s4mainyyYcfU_Tu" = internal global %swift.async_func_pointer
17+
// CHECK-LL: @"$s4main3runyyYFTu" = hidden global %swift.async_func_pointer
1818

1919
// CHECK-LL: define hidden swiftcc void @"$s4main3runyyYF"(%swift.task* {{%[0-9]+}}, %swift.executor* {{%[0-9]+}}, %swift.context* swiftasync {{%[0-9]+}}) {{#[0-9]*}} {
2020
dynamic func run() async {
2121
print("running")
2222
}
2323

24-
runAsyncAndBlock {
25-
await run()
24+
@main struct Main {
25+
static func main() async {
26+
await run()
27+
}
2628
}

0 commit comments

Comments
 (0)