-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff] SR-12526: cross-module @derivative deserialization #30851
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
Conversation
Start fixing SR-12526: `@derivative` attribute cross-module deserialization crash. Remove original `AbstractFunctionDecl *` from `DerivativeAttr` and store `DeclID` instead, mimicking `DynamicReplacementAttr`.
@swift-ci please test |
a4e4fa4
to
2d1436e
Compare
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.
Clever PointerUnion
design, nice!
@swift-ci please test |
1 similar comment
@swift-ci please test |
Build failed |
Wow, I have realized that this PR is completely broken: there is no code path that sets the lazy resolver! The only reason this PR fixes the test is that I add the So I'm going to add a code path that sets the lazy resolver, and I'm going try to make a more robust test. |
Okay, this PR is fixed now. I wasn't able to quickly find any other way of triggering the error other than the missing |
@swift-ci please test |
1 similar comment
@swift-ci please test |
I believe the extra deserialization occurs when a declaration (the missing |
When deserializing a
@derivative
attribute that declares a derivative for a function in a different module, we can't immediately resolve the reference to the function. So this PR adds a lazy resolver to the@derivative
attribute that resolves the original function only when we actually need it (most of this was done by @dan-zheng, thanks!). To handle the case where the@derivative
attribute is parsed and typechecked, we keep theAbstractFunctionDecl*
pointer too. ThegetOriginalFunction
request returns theAbstractFunctionDecl*
if it's available, and otherwise uses the lazy resolver.Resolves SR-12526.