-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Simplify BindingSet construction #86031
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
base: main
Are you sure you want to change the base?
Simplify BindingSet construction #86031
Conversation
6d3c6f2 to
f690933
Compare
|
@swift-ci Please test source compatibility |
|
@swift-ci Please smoke test |
| llvm::SmallVector<LiteralRequirement, 2> Literals; | ||
|
|
||
| llvm::SmallDenseMap<CanType, Constraint *, 2> Defaults; | ||
| llvm::SmallVector<Constraint *, 2> Defaults; |
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.
Does this not make things slower when there duplicate defaultable constraints?
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.
That's a good point, do you mean the same constraint getting added multiple times, or multiple constraints with the same second type? I'll check for both and see if it can happen
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 could be both I think, this is the worst case when multiple type variables form an equivalence class and each has a literal requirement.
| auto &ctx = CS.getASTContext(); | ||
| return Literals.count( | ||
| ctx.getProtocol(KnownProtocolKind::ExpressibleByNilLiteral)); | ||
| for (const auto &literal : Literals) { |
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.
I guess this could also be slimmed down by llvm::any_of
xedin
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.
Looks great, thank you!
The only place where we did a lookup, we also iterated over it anyway, and all remaining usages are simplified by downgrading it to a vector.
…ngSet::BindingSet, and do it at the end
We shouldn't store a pointer to the ConstraintSystem inside every BindingSet, but there are some annoying things to untangle before we can do that. As a starting point toward that, remove the getConstraintSystem() getter so that at least we can't reach up to the ConstraintSystem from the outside.
f690933 to
d795c18
Compare
|
@swift-ci Please smoke test |
|
@swift-ci Please test source compatibility |
The
PotentialBindings::Constraintsset can contain a lot of irrelevant constraints. Removing the iteration over this set fromBindingSet::BindingSetspeeds type checking a large array literal of tuples of integers by ~25%.