-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[AST] NFC: Make ExtInfo param Optional<> #36234
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 |
lib/AST/Builtins.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.
Why the stack allocation rather than inlined into the call? Not that it will make a difference in codegen, but may make the diff easier to read.
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.
For various reasons, I'm not a fan of statements/expressions that overflow a line so this is what felt natural to me. If you feel strongly about this, then I can change the pattern used.
|
Build failed |
|
Build failed |
|
[Not a strong preference but] I think it would be better if there was a single named note (strawman name: |
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.
Defaulting is/was acceptable in all the places in the constraint system since it does want a regular swift escaping function in all of the use sites.
But what about the other ExtInfo bits, for example throwing? I ask also because I have a branch that tries to maintain a "pure" bit but I really doubt that Sema wants to default to impure all of the time. :-/ |
|
All these places where a new function type is created have to do with convenience of |
If |
|
Hi @xedin – So I tried implementing the "has ExtInfo" bit and – at least for the constraint system – eliding the ExtInfo data mostly works. I haven't tried other subsystems. One problem I ran into that the "Equal" constraint does compare ExtInfo data during type matching, so either the type passed to the constraint must have that data, or the type matching needs to treat "no ExtInfo data" as a wildcard during matching. The latter makes me nervous but maybe I shouldn't be. What should we do? |
|
@davezarzycki I'm curious to see the example where |
|
Sure. It's the only one left in CSGen.cpp now that I've implemented the "has ExtInfo" bit. |
|
I think we can replace function use there with |
|
Alright, unfortunately such refactoring wouldn't be as straightforward as it seemed - there are bunch of edge-cases where behavior of patterns in different from regular calls e.g. they allow imploding/exploding arguments and empty inputs of a function e.g. |
|
I believe I have addressed all of the feedback to date. Also, by implementing the "has ExtInfo" bit, I was able to remove a few of the FIXME by simply eliding the @swift-ci please test |
|
Build failed |
|
@swift-ci please clean test linux |
|
Build failed |
|
Build failed |
|
Let's see if I remember how to do cross-repo testing: @swift-ci please test |
|
Build failed |
|
@swift-ci please test macos |
|
Hi @xedin and @varungandhi-apple – So I think I've addressed all of the feedback to date and the two pull requests are ready. |
|
If I understand this correctly, based on your finding, the only place where we need to pass |
|
I've already dropped explicit ExtInfo data from a few places in the compiler where the test suite still passes. In particular, I've removed I'll add the requested |
While it is very convenient to default the ExtInfo state when creating new function types, it also make the intent unclear to those looking to extend ExtInfo state. For example, did a given call site intend to have the default ExtInfo state or does it just happen to work? This matters a lot because function types are regularly unpacked and rebuilt and it's really easy to accidentally drop ExtInfo state. By changing the ExtInfo state to an optional, we can track when it is actually needed.
|
I've added the requested swiftlang/llvm-project#2630 |
|
Ping. I believe I've addressed all of the feedback to date. Might someone please mark this as reviewed? Thanks! |
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.
Sema changes LGMT. I don't like all these FIXMEs very much but that shouldn't block anything.
|
Hi @xedin – Are you approving the whole PR? If not, then who might sign off on the non-sema changes? And just to be clear, this change really helps me with a downstream branch where defaulting the |
|
I think you can land it (we can always revert it) since the behavior is the same everywhere. |
While it is very convenient to default the ExtInfo state when creating new function types, it also make the intent unclear to those looking to extend ExtInfo state. For example, did a given call site intend to have the default ExtInfo state or does it just happen to work? This matters a lot because function types are regularly unpacked and rebuilt and it's really easy to accidentally drop ExtInfo state.