-
Notifications
You must be signed in to change notification settings - Fork 10.5k
TBDGen: Refactor symbol enumeration into SIL and IRGen utilities #61685
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
438e1ab
to
860de29
Compare
@swift-ci please smoke 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.
Thank you for layering these two symbol collectors properly!
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.
Neat!
fa73442
to
45f5963
Compare
@swift-ci please test |
4a7d42c
to
38adf3f
Compare
38adf3f
to
cbc4890
Compare
…SILSymbolVisitor` and `IRSymbolVisitor`.
cbc4890
to
fc20262
Compare
@swift-ci please smoke test and merge |
🎉 |
@swift-ci please smoke test and merge |
TBDGen enumerates all the symbols in a file or module and emits a list of linkable symbols that will be present in the resulting library binary. SILGen and IRGen for
if #_hasSymbol(...)
have similar requirements; given a declaration, we need to enumerate each of the public symbols associated with that declaration to emit a runtime check for that symbol.Given the overlap in requirements, I have factored the core logic of
TBDGenVisitor
into a couple of new visitor classes located inlibswiftSIL
andlibswiftIRGen
and then reimplementedTBDGenVisitor
on top of the new abstractions. The newSILSymbolVisitor
class is responsible for the core enumeration of linkable entities. Entities that can be represented as aSILDeclRef
are enumerated as such, but many other entities do not have a conceptual representation at the SIL layer. The responsibility of representing these is delegated toIRSymbolVisitor
which turns entities intoLinkEntity
instances where possible. Finally, a small number of remaining entities cannot be represented byLinkEntity
and are passed through directly.For the moment, I've tried to reduce the risk of this change by preserving the behavior of
TBDGenVisitor
as much as possible in the new factoring. In the future, though, it's possible that there could be further refactoring and simplification. For instance, some features like Swift API extraction and symbol source map generation could be implemented directly on top ofIRSymbolVisitor
instead of being mixed into the responsibilities ofTBDGenVisitor
. As much as possible, I'd also like to close the gaps where linkable entities cannot be represented bySILDeclRef
orLinkEntity
.