mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Implement value witness table for @differentiable functions (#60875)
@differentiable function is actually a triple (function, jvp, vjp). Previously normal thick function value witness table was used. As a result, for example, only function was copied, but none of differential components. This was the cause of uninitialized memory accesses and subsequent segfaults. Should fix now unavailable TF-1122
This commit is contained in:
committed by
GitHub
parent
983e2f37d3
commit
c89e270b7d
@@ -1337,7 +1337,16 @@ FunctionCacheEntry::FunctionCacheEntry(const Key &key) {
|
||||
if (!flags.isEscaping()) {
|
||||
Data.ValueWitnesses = &VALUE_WITNESS_SYM(NOESCAPE_FUNCTION_MANGLING);
|
||||
} else {
|
||||
Data.ValueWitnesses = &VALUE_WITNESS_SYM(FUNCTION_MANGLING);
|
||||
switch (key.getDifferentiabilityKind().Value) {
|
||||
case FunctionMetadataDifferentiabilityKind::Reverse:
|
||||
Data.ValueWitnesses = &VALUE_WITNESS_SYM(DIFF_FUNCTION_MANGLING);
|
||||
break;
|
||||
default:
|
||||
assert(false && "unsupported function witness");
|
||||
case FunctionMetadataDifferentiabilityKind::NonDifferentiable:
|
||||
Data.ValueWitnesses = &VALUE_WITNESS_SYM(FUNCTION_MANGLING);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user