Commit Graph

577 Commits

Author SHA1 Message Date
Mark Lacey
347b060322 [ConstraintSystem] When we have multiple conversions/fixes, make equality favored.
This allows us to skip attempting actual conversions.

This speeds up one of our slow test cases, and perturbs the output of
another test. In the latter case, we stop emitting conversions as part
of the non-semantic piece of the array_expr. The fact that we're not
putting conversions in on that path is something I've seen before in
other instances. I'll open a bug if I cannot find one for it, although
I believe it's entirely cosmetic in this case since we don't rely on
the conversion being there.
2018-11-15 18:41:53 -08:00
Mark Lacey
540968aa12 Add another type checker test for which we're already quite fast. 2018-11-13 22:18:04 -08:00
Mark Lacey
958ee1a82b Add more type checker performance tests.
Also move one from fast to slow based on the fact that it wasn't
representative of the original issue (which was an expression that
didn't typecheck successfully).
2018-10-25 16:21:17 -07:00
Pavel Yaskevich
70d9b2dfa3 [CSDiagnostics] Fix requirement source lookup to support initializers
Resolves: rdar://problem/45470505
2018-10-22 18:32:32 -07:00
Mark Lacey
5b4a332b0e [ConstraintSystem] Sort the designated types based on actual argument types.
In cases where we have multiple designated types, sort the types that
were designated for this operator based on any information we can
gather about actual argument types at usage sites.

We can consider extending this further in a future commit to ignore
designated types when we have concrete type information that we are
confident of.
2018-10-21 13:14:27 -07:00
Mark Lacey
9a703f584d Update a few more tests to enable -solver-enable-operator-designated-types when possible.
Add the following to all the expression type checker performance tests
that do not regress as a result:

- `-swift-version 5`
- `-solver-disable-shrink`
- `-disable-constraint-solver-performance-hacks`
- `-solver-enable-operator-designated-types`

This is a follow-up to 6de03f709f, where
these should have been included.
2018-10-21 11:47:18 -07:00
Mark Lacey
6de03f709f Update tests to enable -solver-enable-operator-designated-types when possible.
Add the following to all the expression type checker performance tests
that do not regress as a result:

- `-swift-version 5`
- `-solver-disable-shrink`
- `-disable-constraint-solver-performance-hacks`
- `-solver-enable-operator-designated-types`
2018-10-21 10:50:33 -07:00
Mark Lacey
f2f771d2d5 Fix type checker performance test to compile successfully.
At some point this test case was updated such that it no longer
compiled successfully. The originally reported test case did compile
successfully, just slowly.
2018-10-19 10:49:02 -07:00
Mark Lacey
72ba110e5b [ConstraintSystem] Rework new constraint stat as a FRONTEND_STATISTIC.
In the process, remove the old incrementScopeCounter SWIFT_FUNC_STAT.
2018-10-18 07:18:02 -07:00
Mark Lacey
cc0386b461 [ConstraintSystem] Add a new stat to be used for expression type checker performance testing.
This counts the number of leaf scopes we reach while solving the
constraint sytem, and is a much better measure of the growth of
unnecessary work than the total number of scopes opened.

There were two tests where I had a difficult time getting scale-test
to fit the curve even after adjusting some of the parameters, so I've
left those to use the old stat for now.
2018-10-17 07:26:18 -07:00
Mark Lacey
3d6c93f3bd Merge pull request #19909 from rudkx/extend-operator-designated-type
[ConstraintSystem] Extend solver support for designated types for ope…
2018-10-16 10:42:17 -07:00
Mark Lacey
b158651119 [ConstraintSystem] Extend solver support for designated types for operators.
Have the constraint solver consider multiple designated types for an
operator. We currently consider the overloads from each in turn,
stopping as soon as we have a solution. As a result, we can still end
up with exponential type checking in some cases if an operator has
more than a single designated type. This still allows us to reduce the
base of that exponent, though, which makes it possible to increase the
number of expressions we can type check successfully in practice.
2018-10-15 23:51:43 -07:00
Pavel Yaskevich
59899a7911 [ConstraintSystem] Make sure that system is returned into its original state after solving
Currently (with or w/o failures) constraint system is not returned
back to its original state after solving, because constraints from
initial "active" list are not returned to the system. To fix that
let's allocate "initial" scope which captures state right before
solving begins, and add "active" list to the solver state to capture
information about "active" constraints at the time of its creation.

This is follow-up to https://github.com/apple/swift/pull/19873
2018-10-15 16:33:57 -07:00
Greg Parker
9043bf87df [test] Fix a solver flag rename that was missed in #19756. 2018-10-09 18:07:46 -07:00
Mark Lacey
36284ba377 Extend operator decls to allow any designated nominal type for lookup.
Rather than limiting this to protocols, allow any nominal type.

Rename -enable-operator-designated-protocols to
-enable-operator-designated-types to reflect the change.
2018-10-06 17:02:31 -07:00
Mark Lacey
5d6785bec5 Move another typechecker performance test to run with -solver-enable-operator-designated-protocols. 2018-10-04 20:10:13 -07:00
Mark Lacey
e17898c70a Revert a type checker perf test that apparently is still not consistently fast enough. 2018-10-04 15:48:22 -07:00
Mark Lacey
1f517d328d [ConstraintSystem] Distinguish between overloads from a type vs. an extension.
For operators with default implementations in an extension, we don't
want to typecheck it both with overloads from the protocol type and
the ones from the extension.
2018-10-03 18:51:43 -07:00
Mark Lacey
48c6cb40cf Fix release-build test failure due to unaccounted-for warning. 2018-10-03 16:53:04 -07:00
Mark Lacey
472d333a1b Test updates for -solver-enable-operator-designated-protocols.
These are cases that I know are faster when this is enabled. The test
updates all additionally disable the existing performance hacks as
well as the shrink phase of the solver.
2018-10-03 16:01:59 -07:00
Mark Lacey
1d227731c1 [ConstraintSystem] Only use the new disjunction ordering under -swift-version 5.
This will minimize the chance of breaking code. Currently SwiftLint
has one "too complex" expression with this change. Further changes to
the solver may improve that situation, and potentially allow us to
move this out from -swift-version 5 if we're willing to take the risk
of breaking some code as a result.
2018-09-26 14:55:07 -07:00
Mark Lacey
c6c66f6873 [ConstraintSystem] Change the order in which we visit disjunctions.
Attempt to visit disjunctions that are associated with applies where
we have at least some useful information about the types of all of the
arguments before visiting other disjunctions.

Two tests here got faster, and one slightly slower. One of the
faster tests is actually moving from test/ to the slow/ directory in
validation-test because despite going from 16s to less than 1s, it was
still borderline for what we consider the slow threshold, so I made
the test more complex. The one that got a little slower is
rdar22022980, which I also made more complex so that it is clearly
"slow" by the way we are testing it.

slower:
  rdar22022980.swift

faster:
  rdar33688063.swift
  expression_too_complex_4.swift
2018-09-20 13:15:59 -07:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Pavel Yaskevich
a69c6e2964 [CSBindings] Don't record duplicate bindings for opened nominal types
Otherwise it would result in checking the same type multiple times
and results in worse pontential binding picks.
2018-08-30 18:15:55 -07:00
Pavel Yaskevich
f110942097 Merge pull request #19066 from xedin/try-typevar-bindings-cleanup
[CSBindings] Cleanup `tryTypeVariableBindings`
2018-08-30 16:12:51 -07:00
Jordan Rose
296afc7773 [test] Add a test for SR-8493, so we don't regress (#19068)
https://bugs.swift.org/browse/SR-8493
2018-08-30 11:13:01 -07:00
Pavel Yaskevich
2ae8e8d0cb [CSBindings] Cleanup tryTypeVariableBindings
* Move logic to ensure that r-value type var would get r-value type to `PotentialBindings`;
* Strip uncessary parens directly when creating `PotentialBinding`;
* Check if the binding is viable before inclusion in the set, instead of filtering it later;
* Assert that bindings don't have types with errors included in the set.
2018-08-30 00:08:26 -07:00
Ben Cohen
83823f5f7f [stdlib] Obsolete various compatibility shims in 5.0 (#19008)
* Obsolete ModifierSlice typealiases in 5.0

* Obsolete *Indexable in 5.0

* Obsolete IteratorOverOne/EmptyIterator in 5.0

* Obsolete lazy typealiases in 5.0

* Drop .characters from tests

* Obsolete old literal protocols in 5.0

* Obsolete Range conversion helpers in 5.0

* Obsolete IndexDistance helpers in 5.0

* Obsolete Unsafe compat helpers in 5.0

* Obsolete flatMap compatibility helper in 5.0

* Obsolete withMutableCharacters in 5.0

* Obsolete customPlaygroundQuickLook in 5.0

* Deprecate Zip2Sequence streams in 5.0

* Replace * with swift on lotsa stuff

* Back off obsoleting playground conformances for now
2018-08-28 13:20:25 -07:00
Arnold Schwaighofer
b9fe52ed13 Codesign validation-test/Sema/rdar32204609.swift 2018-08-13 08:32:58 -07:00
Pavel Yaskevich
65e67034f8 Merge pull request #18550 from xedin/improve-conformance-req-diags
[Diagnostics] Improve missing conformance diagnostics by using affect…
2018-08-08 00:36:40 -07:00
Pavel Yaskevich
ba085e5bdc [Diagnostics] Improve missing conformance diagnostics for sub-types and members
If generic parameter associated with missing conformance comes
from different context diagnose the problem as "referencing" a
specific declaration from affected type.
2018-08-07 18:55:43 -07:00
Mark Lacey
11eaf7db64 Disable test that seems to be flaky at the moment. 2018-08-07 16:00:08 -07:00
Pavel Yaskevich
ad171e05cc [Diagnostics] Improve missing conformance diagnostics by using affected declaration
Instead of simply pointing out which type had conformance failures,
let's use affected declaration instead, which makes diagnostics much
richer e.g.

```
'List<[S], S.Id>' requires that 'S.Id' conform to 'Hashable'
```

versus

```
initializer 'init(_🆔)' requires that 'E' conform to 'Hashable' [with 'E' = 'S.Id']
```

Since latter message uses information about declaration, it can also
point to it in the source. That makes is much easier to understand when
problem is related to overloaded (function) declarations.
2018-08-07 12:59:53 -07:00
Pavel Yaskevich
c2bf3d5ba9 [TypeChecker] NFC: Fix all of the diagnostics improved by conformance tracking 2018-08-02 21:55:16 -07:00
Mark Lacey
9a3e282066 Temporarily disable performance test that is 'failing' by running too fast.
I am reworking these to be based on the scope counter rather than a
timer.

rdar://problem/42744631
2018-07-30 15:44:37 -07:00
Pavel Yaskevich
ae4e106491 Merge pull request #18281 from xedin/gather-constraints-improvements
[Perf Experiment][ConstraintGraph] Gather constraints improvements
2018-07-28 00:27:36 -07:00
Doug Gregor
fa9a24538f [Standard library] Ascribe types to some literals to improve typecheck time.
One expression in the new hashing implementation is going exponential,
accounting for a huge amount of type-checking type. Add (admittedly ugly)
“as UInt64” annotations to greatly reduce the time to type-check this
expression.

*Ahem* type-checking time for the standard library goes from 24s->14s with
this change. Added a type-checker “slow” performance test and captured
the problem in rdar://problem/42672946.
2018-07-27 14:10:49 -07:00
Pavel Yaskevich
dd798accd8 [ConstraintGraph] Use set to gather constraints for type variables
Since it's possible to find the same constraint through two different
but equivalent type variables, let's use a set to store constraints
instead of a vector to avoid processing the same constraint multiple
times.
2018-07-26 22:41:07 -07:00
Michael Gottesman
be568902f2 [ownership] Always print out ownership argument annotations whether or not -enable-sil-ownership is passed in.
This is how we originally controlled whether or not we printed out ownership
annotations when we printed SIL. Since then, I have changed (a few months ago I
believe) the ownership model eliminator to know how to eliminate these
annotations from the SIL itself. So this hack can be removed.

As an additional benefit, this will let me rename -enable-sil-ownership to
-enable-sil-ownership-verifier. This will I hope eliminate confusion around this
option in the short term while I am preparing to work on semantic sil again.

rdar://42509812
2018-07-24 13:18:37 -07:00
Mark Lacey
c0007f8168 Revert "[ConstraintSystem] Fix the ordering of functions with optional parame…" 2018-07-19 00:21:12 -07:00
Pavel Yaskevich
e1ab6da7a9 [TypeChecker] NFC: Make test-case for rdar://problem/33688063 more complicated
SE-0213 improved cases like that but we still have problem with operator
overloads, so just need to make this a bit more complicated to reproduce again.

Resolves: rdar://problem/42304000
2018-07-18 17:02:20 -07:00
Mark Lacey
eca92003bc Merge pull request #17855 from rudkx/rdar19748710
[ConstraintSystem] Fix the ordering of functions with optional parame…
2018-07-18 14:31:17 -07:00
Mark Lacey
d271f4b057 [ConstraintSystem] Ensure we prefer f(_: Any) to f(_: Any?) when both work.
...unless the argument is an `Any?`, in which case we prefer `f(_: Any?)`.

This change also results in our selecting f<T>(_: T) over f(_:
Any). Coercing with 'as Any' makes it possible to explicitly select
the Any overload. Previously there was no way to select the generic
overload.
2018-07-18 11:44:04 -07:00
Pavel Yaskevich
aa9b3d8474 [TypeChecker] SE-0213: Implement literal init via coercion
Implementation is as follows: In `preCheckExpression` try to
detect if there is `T(literal)` call in the AST, replace it with
implicit `literal as T`, while trying to form type-checked AST,
after constraint solving, restore source information and drop
unnecessary coercion expression.

Resolves: rdar://problem/17088188
Resolves: rdar://problem/39120081
Resolves: rdar://problem/23672697
Resolves: rdar://problem/40379985
2018-07-17 12:08:59 -07:00
Matt Diephouse
35592747db Change "enum element" to "enum case" in diagnostics
From the perspective of the compiler implementation, they're elements. But users will think of these as cases—and many diagnostics already refer to these as enum cases.
2018-07-15 16:01:10 -04:00
Jordan Rose
93fb20fcbc Add a test for SR-8209, which seems to be fixed (#17838)
https://bugs.swift.org/browse/SR-8209
2018-07-10 14:09:58 -07:00
Slava Pestov
28b0606b46 'Migrate' compiler crashers to Swift 4 2018-07-03 16:03:07 -07:00
Mark Lacey
0a46b4b040 Merge pull request #17663 from rudkx/adjust-test-complexity
Adjust several type checker perf tests to be more complex.
2018-07-01 17:30:52 -07:00
Mark Lacey
8d980c9616 Adjust several type checker perf tests to be more complex.
None of these failed naturally based on the limits of the "too
complex" heuristic and several were relatively closer to the time-out
threshold used in the test RUN line.

Increasing the complexity will ensure that we don't see spurious
failures on builders or on local machines.
2018-07-01 14:41:49 -07:00
Mark Lacey
a4068663ba This test case isn't really fast, and failed a few times for me locally.
Make it more complex to ensure that it fails consistently in the slow
directory.
2018-06-30 11:25:44 -07:00