Commit Graph

195 Commits

Author SHA1 Message Date
Slava Pestov
cfcc73f164 Sema: Add -solver-disable-splitter flag for debugging
We're not planning on removing the splitter because it is a big win
in some cases, but we want to run it less often since it can also
be a source of overhead. This flag allows us to compare performance
to understand the tradeoffs better.
2025-01-15 22:30:33 -05:00
Slava Pestov
9fb6d9251e Sema: Remove DependentComponentSplitterStep 2024-12-21 00:42:13 -08:00
Slava Pestov
dd3e49c3ac Sema: Remove one-way constraint handling from computeConnectedComponents() 2024-12-21 00:42:13 -08:00
Pavel Yaskevich
e404ed722a [CSStep] Don't favor choices until the disjunction is picked 2024-12-17 11:36:38 -08:00
Slava Pestov
27812856dc Sema: Extend DisjunctionStep::shouldSkip() hack to cover ~ & | ^ << >> 2024-12-16 18:08:01 -05:00
Slava Pestov
7fef225c9f Sema: Allow turning off expression timer with -solver-expression-time-threshold=0 2024-11-20 13:46:19 -05:00
Slava Pestov
c8415aeac4 Sema: Record the trail step count in solver statistics
Also introduce two new frontend flags:

The -solver-scope-threshold flag sets the maximum number of scopes, which was
previously hardcoded to 1 million.

The -solver-trail-threshold flag sets the maximum number of trail steps,
which defaults to 64 million.
2024-11-20 13:46:19 -05:00
Slava Pestov
65def070dc Sema: Remove similar weirdness from ~ConjunctionStep 2024-10-21 17:21:09 -04:00
Slava Pestov
e0b6a96f0e Sema: Retire disjunctions in trail instead of restoring in ~DisjunctionStep
Fixes https://github.com/swiftlang/swift/issues/77008.
2024-10-21 17:19:33 -04:00
Slava Pestov
6c2e4ecb80 Sema: Rename restoreCurrentScore() to updateScoreAfterConjunction() 2024-10-09 11:48:07 -04:00
Slava Pestov
38fe0696a4 Sema: Factor out clearScore() and replayScore() 2024-10-09 11:48:07 -04:00
Slava Pestov
e9add92334 Sema: Remove some unnecessary heap allocation of SolverScopes 2024-10-08 17:23:38 -04:00
Slava Pestov
0b85ce6f00 Sema: Remove SolverScope::numFixes 2024-10-08 16:57:49 -04:00
Slava Pestov
1e2d4fbc59 Sema: Record score increases in the trail 2024-10-08 16:16:31 -04:00
Slava Pestov
877c60e3d0 Sema: Rename applySolution() to replaySolution() 2024-10-08 16:16:01 -04:00
Slava Pestov
e70d0bc6fa Sema: Add missing newline in debug output 2024-09-29 21:48:08 -04:00
Slava Pestov
4d980ecbc4 Sema: Reset best score for conjunction element 2024-09-24 19:24:32 -04:00
Slava Pestov
73561e821f Sema: Check worseThanBestSolution() in a better place 2024-09-24 19:24:18 -04:00
Slava Pestov
e8d717bcd6 AST: Remove ModuleDecl parameter from checkRequirements() 2024-07-06 12:05:46 -04:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Slava Pestov
f0f9c56409 Sema: Better -debug-constraints output when we failed because of free type variables 2024-04-30 16:10:36 -04:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Slava Pestov
8f939c4a34 AST: Remove unused computation from IsBindableVisitor 2024-02-19 14:53:07 -06:00
Pavel Yaskevich
aa8705c876 Merge pull request #70956 from xedin/fix-nullptr-in-isdeclrefinement-of
[CSStep] Add a nullptr check to `IsDeclRefinementOfRequest::evaluate`
2024-01-17 09:18:18 -08:00
Pavel Yaskevich
9eb7ff9d7e [CSStep] Add a nullptr check to IsDeclRefinementOfRequest::evaluate
Interface type of an archetype is not always represented by a
`SubstitutableType`, it could be a `DependentMemberType` as well.

The code in `IsDeclRefinementOfRequest::evaluate` already partially
accounts for that by using `getAs` but the nullptr check is missing
which means that the resulting substitution map is incorrect.
2024-01-17 01:07:26 -08:00
Slava Pestov
1e950b1725 AST: Move checkGenericArguments() to AST and rename to checkRequirements() 2024-01-16 14:47:50 -05:00
Pavel Yaskevich
f4ec76ea45 [CSStep] NFC: Address a warning about use of deprecated .startswith_insensitive 2024-01-12 11:39:38 -08:00
Alex Hoppen
655c8f4865 [Sema] Check cs.isForCodeCompletion() instead of checking for presence of CompletionCallback
This shouldn’t really change anything but is just a little cleaner.
2023-09-08 08:23:38 -07:00
Hamish Knight
6ede5e050f [CodeComplete] Avoid dropping "is for code completion" bit
This should no longer be needed now that we check for a code
completion token when increasing the score. It should also
allow us to skip more conjunction elements, as that requires
the bit being set.
2023-08-03 21:16:10 +01:00
Hamish Knight
1dd86fccdb [CodeComplete] More efficient skipping for completions in if/switch exprs
Skip type-checking multi-statement branches if the
completion is in a single-expression branch, and
skip type-checking the expression as a whole if
the completion is in a multi-statement branch.
2023-08-01 15:21:29 +01:00
Alex Hoppen
1bacfe9cd4 [IDE] Ignore unspported constructs in result builders in code completion mode 2023-07-07 19:51:01 +02:00
Alex Hoppen
6cec68e302 [IDE] Ignore score kinds that represent implicit conversions when solving for code completion
Ignore conversion score increases during code completion to make sure we don't filter solutions that might start receiving the best score based on a choice of the code completion token.
2023-07-07 19:50:46 +02:00
Pavel Yaskevich
8a26df8166 [ConstraintSystem] NFC: Standardize the way of type holefication
Introduce `ConstraintSystem::recordTypeVariablesAsHoles` as a
standard way to record that unbound type variables found in a
type are holes in the given constraint system.
2023-04-21 15:22:13 -07:00
Hamish Knight
a40f1abaff Introduce if/switch expressions
Introduce SingleValueStmtExpr, which allows the
embedding of a statement in an expression context.
This then allows us to parse and type-check `if`
and `switch` statements as expressions, gated
behind the `IfSwitchExpression` experimental
feature for now. In the future,
SingleValueStmtExpr could also be used for e.g
`do` expressions.

For now, only single expression branches are
supported for producing a value from an
`if`/`switch` expression, and each branch is
type-checked independently. A multi-statement
branch may only appear if it ends with a `throw`,
and it may not `break`, `continue`, or `return`.

The placement of `if`/`switch` expressions is also
currently limited by a syntactic use diagnostic.
Currently they're only allowed in bindings,
assignments, throws, and returns. But this could
be lifted in the future if desired.
2023-02-01 15:30:18 +00:00
Hamish Knight
b3c12cabf9 [CS] NFC: Move SolverSnapshot::applySolution into the cpp file 2023-02-01 15:30:17 +00:00
Erik Eckstein
7d8bf37e5e change to the new llvm::Optional APIs
This is a follow-up of https://github.com/apple/swift/pull/62217
2023-01-25 09:18:36 +01:00
Alex Hoppen
3c90c892e9 [CodeCompletion] Drop ForCodeCompletion constraint system option for syntactic elements that don't contain completion token 2022-12-21 12:17:56 -08:00
Pavel Yaskevich
6b3776456c Merge pull request #62053 from abdulowork/improve-type-checker-debugging-indentation
Improve indentation in type checker debugging output
2022-11-30 12:11:27 -08:00
Timofey Solonin
3f366947e4 Improve indentation in debugging output 2022-11-17 23:25:31 +08:00
Timofey Solonin
3c401a1c7e Fix unbalanced braces in debugging output 2022-11-17 22:26:19 +08:00
Hamish Knight
f2404feb91 [CS] Factor out BindingSet::favoredOverConjunction
And refactor the way we select the next step for
a ComponentStep. This should be NFC.
2022-11-14 20:03:41 +00:00
Amritpan Kaur
254bd8262a [CSStep] Fix type variable printing inconsistency. 2022-09-12 13:07:37 -07:00
Amritpan Kaur
7c3cb4f570 [CSBindings] Fix double printing of type variables.
Fix spacing when printing initial Type Variables. Add
line break to bindings that print under Potential Bindings.
2022-09-01 20:44:04 -07:00
Amritpan Kaur
5784f74b29 [CSStep] Fix extraneous ) printed during nested ConjunctionSteps.
~ConjunctionStep called before all steps are finished.
2022-09-01 20:25:18 -07:00
Amritpan Kaur
f683c2ca16 [CSStep] Remove extraneous ) printing after PotentialBindings/Disjunctions.
Moved `debugLogger` into each if-block so it's indentation doesn't affect next `isDebugMode`.
2022-08-25 15:19:21 -07:00
Amritpan Kaur
72190ed7fa [CSStep] Print disjunctions with bindOverload choices.
Print all disjunctions in scope, not just the one selected. Remove conjunction printing.
2022-08-25 15:19:19 -07:00
Amritpan Kaur
51281c54c4 [CSBindings] Move binding printing out of determineBestBindings and check that bindings exist before printing. 2022-08-22 16:26:45 -07:00
Amritpan Kaur
177f136164 [CSStep] Add disjunction and conjunction printing to initial state displayed during component step. 2022-08-20 18:03:30 -07:00
Amritpan Kaur
e3e446b918 [CSStep] Remove previous "Initial binding" output. 2022-08-20 18:03:30 -07:00