Files
swift-mirror/test/AutoDiff/SILOptimizer/param_thunk_tuple.swift
Pavel Yaskevich 60ea598e7f [SIL] Set actor isolation when constructing/initializing SILFunction
Prevents situations when actor isolation ends up not being set
un-intentionally i.e. when cloning, specializating, or creating
thunks.

The thunks get `unspecified` isolation at the moment.
2026-04-21 16:03:35 -07:00

36 lines
1.2 KiB
Swift

// RUN: %target-swift-frontend -Xllvm -sil-print-types -emit-sil %s | %FileCheck %s
// Verify the result type of a subset parameters thunk matches the declaration:
//
// CHECK: // autodiff subset parameters thunk for forward-mode derivative from f(x:)
// CHECK-NEXT: // Isolation: unspecified
// CHECK-NEXT: sil shared [transparent] [thunk] @$s17param_thunk_tuple{{.*}} : $@convention(thin) (X)
// CHECK-SAME: -> (Float, Double, @owned @callee_guaranteed (X.TangentVector) -> Float)
// CHECK: return
// CHECK-SAME: %{{.*}} : $(Float, Double, @callee_guaranteed (X.TangentVector) -> Float)
//
// CHECK: // autodiff subset parameters thunk for reverse-mode derivative from f(x:)
// CHECK-NEXT: // Isolation: unspecified
// CHECK-NEXT: sil shared [transparent] [thunk] @$s17param_thunk_tuple{{.*}} : $@convention(thin) (X)
// CHECK-SAME: -> (Float, Double, @owned @callee_guaranteed (Float) -> X.TangentVector)
// CHECK: return
// CHECK-SAME: %{{.*}} : $(Float, Double, @callee_guaranteed (Float) -> X.TangentVector)
import _Differentiation
struct X: Differentiable {
var a: Float
var b: Double
}
@differentiable(reverse)
func f(x: X) -> (Float, Double) {
(x.a, x.b)
}
@differentiable(reverse)
func g1(x: X) -> Float {
f(x: x).0
}