-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Constraint System] Implement heuristics for linked operator expressions in the solver proper. #34399
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
Merged
hborla
merged 18 commits into
swiftlang:main
from
hborla:optimize-linked-operator-solving
Nov 8, 2020
Merged
[Constraint System] Implement heuristics for linked operator expressions in the solver proper. #34399
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e0199f2
Add condition for optimizing series of binops that every possible ove…
gregomni 2edba9d
Instead of chaining binops, favor disjunctions with op overloads whos…
gregomni c84bd00
[ConstraintSystem] Move getResolvedOverloads() from CSStep to Constra…
hborla b06f749
[ConstraintSystem] Fix build failures and formatting.
hborla ab6d92b
Favor operators based on existing binds via both basename and type
gregomni 34fa9c2
Merge typevars of operators with shared decls after finding a solutio…
gregomni cb64d7f
[ConstraintSystem] Fix build failures.
hborla 91291c7
Dump disjunction possibilities on multiple aligned lines for better r…
gregomni b9e08b2
[ConstraintSystem] Allow the solver to find other solutions after
hborla 8dd2008
[Test] Adjust type checker performance tests
hborla c9100c4
[ConstraintSystem] Instead of favoring existing operator bindings,
hborla a8fcdb8
[ConstraintSystem] Remove an unnecessary SIMD special case in
hborla 423d6bd
[ConstraintSystem] Re-instate the operator type variable merging
hborla 0d8a161
[NFC][ConstraintSystem] Update the documentation for
hborla 0995608
[ConstraintSystem] Only factor in existing operator bindings in
hborla abfc903
[ConstraintSystem] For generic operators, only consider exact decls that
hborla 12dce85
[NFC][ConstraintSystem] Use llvm::count_if for the count methods on
hborla 2507a31
[Test] Add a slow type checker test case from source compatibility su…
hborla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -367,7 +367,7 @@ namespace { | |
} | ||
}; | ||
|
||
simplifyBinOpExprTyVars(); | ||
simplifyBinOpExprTyVars(); | ||
|
||
return true; | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// RUN: %target-swift-frontend -typecheck -verify %s | ||
|
||
// REQUIRES: rdar65007946 | ||
|
||
struct A { | ||
static func * (lhs: A, rhs: A) -> B { return B() } | ||
static func * (lhs: B, rhs: A) -> B { return B() } | ||
static func * (lhs: A, rhs: B) -> B { return B() } | ||
} | ||
struct B {} | ||
|
||
let (x, y, z) = (A(), A(), A()) | ||
|
||
let w = A() * A() * A() // works | ||
|
||
// Should all work | ||
let a = x * y * z | ||
let b = x * (y * z) | ||
let c = (x * y) * z | ||
let d = x * (y * z as B) | ||
let e = (x * y as B) * z |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
validation-test/Sema/type_checker_perf/fast/rdar18360240.swift.gyb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...type_checker_perf/slow/rdar23429943.swift → ...type_checker_perf/fast/rdar23429943.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1 | ||
// REQUIRES: tools-release,no_asan | ||
|
||
// expected-error@+1 {{the compiler is unable to type-check this expression in reasonable time}} | ||
let _ = [0].reduce([Int]()) { | ||
return $0.count == 0 && ($1 == 0 || $1 == 2 || $1 == 3) ? [] : $0 + [$1] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
validation-test/Sema/type_checker_perf/slow/mixed_string_array_addition.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// RUN: %target-typecheck-verify-swift -swift-version 5 -solver-expression-time-threshold=1 | ||
|
||
func method(_ arg: String, body: () -> [String]) {} | ||
|
||
func test(str: String, properties: [String]) { | ||
// expected-error@+1 {{the compiler is unable to type-check this expression in reasonable time}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't new, but a case I discovered when debugging the source compat failures. This compiles (very slowly) if you add a type annotation to |
||
method(str + "" + str + "") { | ||
properties.map { param in | ||
"" + param + "" + param + "" | ||
} + [""] | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.