-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ABI] [AutoDiff] Fix function differentiability kind metadata and mangling. #36601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ABI] [AutoDiff] Fix function differentiability kind metadata and mangling. #36601
Conversation
7e6607d
to
d617f0e
Compare
} | ||
return TargetFunctionMetadataDifferentiabilityKind<StoredSize> | ||
::NonDifferentiable; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use swift/ABI/TrailingObjects.h
to help with the trailing allocation management here. Where do you initialize the tail storage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, initially I wanted to use that but noticed that parameters and parameter flags are tail-allocated manually, so I followed the same approach. Would it be odd to mix both, no? The allocation size calculation is in FunctionCacheEntry::getExtraAllocationSize()
; I aligned the previously calculated size (because there are a few 32-bit ints for parameter flags) and appended a differentiability word after it.
65286df
to
e6fe273
Compare
@@ -1785,6 +1798,15 @@ class OldDemangler { | |||
if (async) { | |||
block->addChild(Factory.createNode(Node::Kind::AsyncAnnotation), Factory); | |||
} | |||
if (concurrent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part seemed missing sendable
handling so I added it.
lib/IRGen/MetadataRequest.cpp
Outdated
.withNumParameters(numParams) | ||
.withConvention(metadataConvention) | ||
.withAsync(type->isAsync()) | ||
.withConcurrent(type->isConcurrent()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part seemed missing sendable
handling so I added it.
@swift-ci please test |
Build failed |
* Move differentiability kinds from target function type metadata to trailing objects so that we don't exhaust all remaining bits of function type metadata. * Fix mangling of different differentiability kinds in function types. Mangle it like `ConcurrentFunctionType` so that we can drop special cases for escaping functions. Resolves rdar://75240064.
e6fe273
to
f5282ed
Compare
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks Richard!
swift_getFunctionTypeMetadataDifferentiable
which handles differentiable function types.ConcurrentFunctionType
so that we can drop special cases for escaping functions.Resolves rdar://75240064.