Files
swift-mirror/test/AutoDiff/SILGen/mangling.swift
Joe Groff 69e4b95fb8 SIL: Model noescape partial_applys with ownership in OSSA.
Although nonescaping closures are representationally trivial pointers to their
on-stack context, it is useful to model them as borrowing their captures, which
allows for checking correct use of move-only values across the closure, and
lets us model the lifetime dependence between a closure and its captures without
an ad-hoc web of `mark_dependence` instructions.

During ownership elimination, We eliminate copy/destroy_value instructions and
end the partial_apply's lifetime with an explicit dealloc_stack as before,
for compatibility with existing IRGen and non-OSSA aware passes.
2023-02-16 21:43:53 -08:00

24 lines
1.2 KiB
Swift

// RUN: %target-swift-frontend -module-name mangling -Xllvm -sil-full-demangle %s -emit-silgen | %FileCheck %s
// Note: adapted from test/SILGen/mangling.swift.
import _Differentiation
// CHECK-LABEL: sil hidden [ossa] @$s8mangling15nonescapingFunc2fnyS2fXE_tF :
func nonescapingFunc(fn: (Float) -> Float) {}
// CHECK-LABEL: sil hidden [ossa] @$s8mangling8diffFunc2fnyS2fYjrXE_tF :
func diffFunc(fn: @differentiable(reverse) (Float) -> Float) {}
// CHECK-LABEL: sil hidden [ossa] @$s8mangling10linearFunc2fnyS2fYjlXE_tF :
func linearFunc(fn: @differentiable(_linear) (Float) -> Float) {}
// CHECK-LABEL: sil hidden [ossa] @$s8mangling12escapingFunc2fnS2fcS2fc_tF :
func escapingFunc(fn: @escaping (Float) -> Float) -> (Float) -> Float { fn }
// CHECK-LABEL: sil hidden [ossa] @$s8mangling16diffEscapingFunc2fnS2fYjrcS2fYjrc_tF :
func diffEscapingFunc(fn: @escaping @differentiable(reverse) (Float) -> Float) -> @differentiable(reverse) (Float) -> Float { fn }
// CHECK-LABEL: sil hidden [ossa] @$s8mangling18linearEscapingFunc2fnS2fYjlcS2fYjlc_tF :
func linearEscapingFunc(fn: @escaping @differentiable(_linear) (Float) -> Float) -> @differentiable(_linear) (Float) -> Float { fn }