Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion test/IRGen/async_wasm.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %target-swift-frontend -primary-file %S/async.swift -enable-builtin-module -emit-ir -disable-availability-checking | %FileCheck %s --check-prefix=NOTAIL
// TODO(katei): %target-swift-frontend -primary-file %S/async.swift -enable-builtin-module -emit-ir -disable-availability-checking -Xcc -mtail-call | %FileCheck %s --check-prefix=TAIL
// RUN: %target-swift-frontend -primary-file %S/async.swift -enable-builtin-module -emit-ir -disable-availability-checking -Xcc -mtail-call | %FileCheck %s --check-prefix=TAIL

// REQUIRES: concurrency && CPU=wasm32

Expand All @@ -11,3 +11,11 @@
// NOTAIL-NOT: @swift_task_alloc
// NOTAIL-NOT: musttail call
// NOTAIL: call swiftcc void @swift_task_future_wait_throwing(ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, ptr {{.*}})

// TAIL: "$s5async1fyyYaF"
// TAIL: "$s5async1gyyYaKF"
// TAIL: "$s5async1hyyS2iYbXEF"

// TAIL: define{{.*}} swifttailcc void @"$s5async8testThisyyBonYaF"(ptr swiftasync %0{{.*}}
// TAIL-NOT: @swift_task_alloc
// TAIL: musttail call swifttailcc void @swift_task_future_wait_throwing(ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, ptr {{.*}})
34 changes: 34 additions & 0 deletions test/IRGen/async_wasm_tailcall.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Verify that async coroutine splitting on Wasm uses musttail/return_call
// with the tail-call feature and regular calls without it.

// IR-level checks:
// RUN: %target-swift-frontend %s -emit-ir -module-name test -disable-availability-checking | %FileCheck %s --check-prefix=NOTAIL
// RUN: %target-swift-frontend %s -emit-ir -module-name test -disable-availability-checking -Xcc -mtail-call | %FileCheck %s --check-prefix=TAIL

// Assembly-level checks:
// RUN: %target-swift-frontend %s -S -module-name test -disable-availability-checking -Xcc -mtail-call | %FileCheck %s --check-prefix=TAIL-ASM
// RUN: %target-swift-frontend %s -S -module-name test -disable-availability-checking | %FileCheck %s --check-prefix=NOTAIL-ASM

// REQUIRES: concurrency
// REQUIRES: CPU=wasm32

func callee() async -> Int { return 42 }

public func caller() async -> Int {
return await callee()
}

// Without -mtail-call: async functions use swiftcc, no musttail
// NOTAIL: define {{.*}}swiftcc void @"$s4test6callerSiyYaF"(ptr swiftasync
// NOTAIL-NOT: musttail call

// With -mtail-call: async functions use swifttailcc with musttail
// TAIL: define {{.*}}swifttailcc void @"$s4test6callerSiyYaF"(ptr swiftasync
// TAIL: musttail call swifttailcc void

// Assembly with -mtail-call: return_call Wasm instruction
// TAIL-ASM: return_call

// Assembly without -mtail-call: no return_call Wasm instruction
// NOTAIL-ASM: .functype
// NOTAIL-ASM-NOT: return_call
38 changes: 38 additions & 0 deletions test/embedded/concurrency-tailcall.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Verify that embedded async coroutine splitting on Wasm uses
// musttail/return_call with the tail-call feature and regular calls without it.

// IR-level checks:
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -parse-as-library -module-name test %s -emit-ir | %FileCheck %s --check-prefix=NOTAIL
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -parse-as-library -module-name test %s -emit-ir -Xcc -mtail-call | %FileCheck %s --check-prefix=TAIL

// Assembly-level checks:
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -parse-as-library -module-name test %s -S -Xcc -mtail-call | %FileCheck %s --check-prefix=TAIL-ASM
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -parse-as-library -module-name test %s -S | %FileCheck %s --check-prefix=NOTAIL-ASM

// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: OS=wasip1
// REQUIRES: swift_feature_Embedded

import _Concurrency

func callee() async -> Int { return 42 }

public func caller() async -> Int {
return await callee()
}

// Without -mtail-call: async functions use swiftcc, no musttail
// NOTAIL: define {{.*}}swiftcc void @"$e4test6callerSiyYaF"(ptr swiftasync
// NOTAIL-NOT: musttail call

// With -mtail-call: async functions use swifttailcc with musttail
// TAIL: define {{.*}}swifttailcc void @"$e4test6callerSiyYaF"(ptr swiftasync
// TAIL: musttail call swifttailcc void

// Assembly with -mtail-call: return_call Wasm instruction
// TAIL-ASM: return_call

// Assembly without -mtail-call: no return_call Wasm instruction
// NOTAIL-ASM: .functype
// NOTAIL-ASM-NOT: return_call