-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[IRGen] Propagate locally-cached metadata completion to transitive dependencies. #69400
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
[IRGen] Propagate locally-cached metadata completion to transitive dependencies. #69400
Conversation
4ca6279 to
8a7179e
Compare
|
@swift-ci please apple silicon benchmark |
|
@swift-ci please test |
lib/IRGen/LocalTypeData.cpp
Outdated
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.
Hmm. I think this is going to force abstract entries in the LocalTypeData cache to emitted (abstract in the sense of the LTDC, i.e. metadata that can cheaply be produced). We probably don't want that; it might have a lot of extra compile-time cost, even if LLVM can eliminate it later.
It might be easiest to just add a new operation on the LTDC, some sort of update-state-in-scope operation. The initial implementation can just affect concrete entries, but in principle we could also make this work with abstract entries by cloning the abstract path and then telling it to override the completeness.
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.
Fixed. Added an advanceStateInScope operation to LTDC. It looks for relevant cache entries and updates the cache accordingly. There are TODOs for the abstract case. If a relevant concrete entry is found (i.e. one whose dominance point dominates the active dominance point), it's used to produce a new cache entry whose dominance point is the active dominance point and whose state is the one specified.
lib/IRGen/LocalTypeData.cpp
Outdated
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.
It's sortof implied by the code, but please update the comment to talk about transitively-complete metadata rather than the vaguer "all of the metadata it references".
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.
Fixed.
When metadata record for a generic type is locally cached as ::Complete, the metadata is known to be complete in that scope. If it's for a generic type, being complete means that all of its recursive generic arguments are also complete. Previously, though, that fact was not exploited. So a metadata record for such an argument which was originally obtained via an incomplete request would remain cached in that incomplete state even when a generic type in which it appeared as a generic argument was cached as complete. At worst, the result was a runtime call (checkMetadataState) to promote the complete the metadata record for the recursive argument. Here, when a bound generic type's metadata is locally cached as complete, its recursive generic arguments are visited; for each such type for which a metadata record is already locally cached, the preexisting record is recached as complete.
8a7179e to
b8990b5
Compare
|
@swift-ci please apple silicon benchmark |
|
@swift-ci please test |
|
rjmccall
left a comment
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 looks great!
|
Nice! |
When metadata record for a generic type is locally cached as ::Complete, the metadata is known to be complete in that scope. If it's for a generic type, being complete means that all of its recursive generic arguments are also complete.
Previously, though, that fact was not exploited. So a metadata record for such an argument which was originally obtained via an incomplete request would remain cached in that incomplete state even when a generic type in which it appeared as a generic argument was cached as complete. At worst, the result was a runtime call (checkMetadataState) to promote the complete the metadata record for the recursive argument.
Here, when a bound generic type's metadata is locally cached as complete, its recursive generic arguments are visited; for each such type for which a metadata record is already locally cached, the preexisting record is recached as complete.