mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The main point of this change is to make sure that a shared function always has a body: both, in the optimizer pipeline and in the swiftmodule file. This is important because the compiler always needs to emit code for a shared function. Shared functions cannot be referenced from outside the module. In several corner cases we missed to maintain this invariant which resulted in unresolved-symbol linker errors. As side-effect of this change we can drop the shared_external SIL linkage and the IsSerializable flag, which simplifies the serialization and linkage concept.
44 lines
2.6 KiB
Plaintext
44 lines
2.6 KiB
Plaintext
// RUN: %target-sil-opt -differentiability-witness-devirtualizer %s -enable-sil-verify-all | %FileCheck %s
|
|
|
|
sil_stage raw
|
|
|
|
import _Differentiation
|
|
import Swift
|
|
import Builtin
|
|
|
|
sil_differentiability_witness [reverse] [parameters 0] [results 0] @witness_defined_in_module : $@convention(thin) (Float) -> Float {
|
|
jvp: @witness_defined_in_module_jvp : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
|
|
vjp: @witness_defined_in_module_vjp : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
|
|
}
|
|
|
|
sil_differentiability_witness [reverse] [parameters 0] [results 0] @witness_definition_not_available : $@convention(thin) (Float) -> Float
|
|
|
|
// This is an example of a witness that is available (via deserialization)
|
|
// even though it is not defined in the current module.
|
|
// witness for static Swift.Float.+ infix(Swift.Float, Swift.Float) -> Swift.Float
|
|
sil_differentiability_witness [reverse] [parameters 0 1] [results 0] @$sSf1poiyS2f_SftFZ : $@convention(method) (Float, Float, @thin Float.Type) -> Float
|
|
|
|
sil @witness_defined_in_module : $@convention(thin) (Float) -> Float
|
|
|
|
sil @witness_defined_in_module_jvp : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
|
|
|
|
sil @witness_defined_in_module_vjp : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
|
|
|
|
sil @witness_definition_not_available : $@convention(thin) (Float) -> Float
|
|
|
|
sil public_external [transparent] @$sSf1poiyS2f_SftFZ : $@convention(method) (Float, Float, @thin Float.Type) -> Float
|
|
|
|
sil @test : $@convention(thin) (Float) -> () {
|
|
bb0(%0 : $Float):
|
|
%1 = differentiability_witness_function [vjp] [reverse] [parameters 0] [results 0] @witness_defined_in_module : $@convention(thin) (Float) -> Float
|
|
// CHECK: function_ref @witness_defined_in_module_vjp : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
|
|
|
|
%2 = differentiability_witness_function [vjp] [reverse] [parameters 0] [results 0] @witness_definition_not_available : $@convention(thin) (Float) -> Float
|
|
// CHECK: differentiability_witness_function [vjp] [reverse] [parameters 0] [results 0] @witness_definition_not_available : $@convention(thin) (Float) -> Float
|
|
|
|
%3 = differentiability_witness_function [vjp] [reverse] [parameters 0 1] [results 0] @$sSf1poiyS2f_SftFZ : $@convention(method) (Float, Float, @thin Float.Type) -> Float
|
|
// CHECK: function_ref @$sSf1poiyS2f_SftFZTJrSSUpSr : $@convention(method) (Float, Float, @thin Float.Type) -> (Float, @owned @callee_guaranteed (Float) -> (Float, Float))
|
|
|
|
return undef : $()
|
|
}
|