-
Notifications
You must be signed in to change notification settings - Fork 10.5k
SILGen: Implement if #_hasSymbol(...)
conditions
#61563
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
@swift-ci please test |
|
||
func->getAttrs().add(new (ctx) SILGenNameAttr(mangledName, IsImplicit)); | ||
return func; | ||
} |
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.
Would it help the inlinable case to write that synthesized function in the swiftinterface (and swiftmodule) as usable from inline?
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 doesn't help directly. The function body cannot be spelled in Swift (or even SIL) today so we can't emit the implementation of the helper function. Emitting just the function declaration with some kind of indication that it needs special treatment is doable but it also doesn't help with the crux of the problem, which is reconstituting the VarDecl *
that we need to pass down to IRGen.
These are my ideas for lifting the restriction in the future:
- Invent a new SIL instruction for the
#_hasSymbol()
condition that, when serialized, serializes theVarDecl *
so that we can re-derive the helper function. - Make SIL capable of representing the logic of the helper function, in which case we generate the helper function in SILGen instead of IRGen.
7889607
to
23350ac
Compare
@swift-ci please smoke test and merge |
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.
Very cool!
Emit a call to a helper function that determines whether the symbols associated with the declaration referenced in the `#_hasSymbol(...)` condition are non-null at runtime. An upcoming change will emit a definition for this function during IRGen. Resolves rdar://100130015
23350ac
to
8a9eb40
Compare
@swift-ci please smoke test and merge |
Emit a call to a helper function that determines whether the symbols associated with the declaration referenced in the
#_hasSymbol(...)
condition are non-null at runtime. An upcoming change will emit a definition for this function during IRGen.The current implementation strategy is not compatible with
if #_hasSymbol()
appearing in inlinable code since theValueDecl *
referenced by the condition would need to be recoverable when deserializing SIL. For now, diagnose the syntax when it appears in fragile functions.Resolves rdar://100130015