Hamish Knight
edca7c85ad
Adopt ABORT throughout the compiler
...
Convert a bunch of places where we're dumping to stderr and calling
`abort` over to using `ABORT` such that the message gets printed to
the pretty stack trace. This ensures it gets picked up by
CrashReporter.
2025-05-19 20:55:01 +01:00
Slava Pestov
273c4b2b1a
RequirementMachine: Convert to new assertions
2024-06-22 08:53:22 -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
8afff61699
AST: Replace TypeArrayView<GenericTypeParamType> with ArrayRef<GenericTypeParamType *>
...
This basically undoes 3da6fe9c0d , which in hindsight was wrong.
There were no other usages of TypeArrayView anywhere else except for
GenericSignature::getGenericParams(), and it was almost never what
you want, so callers had to convert back and forth to an ArrayRef.
Remove it.
2023-06-29 19:23:44 -04:00
Erik Eckstein
ab1b343dad
use new llvm::Optional API
...
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`
The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.
rdar://102362022
2022-11-21 19:44:24 +01:00
Josh Soref
81d3ad76ac
Spelling ast ( #42463 )
...
* spelling: accessor
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: accommodates
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: argument
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: associated
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: availability
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: available
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: belongs
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: bookkeeping
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: building
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: clazz
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: clonable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: closure
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: concatenated
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: conformance
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: context
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: conversion
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: correspondence
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: declarations
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: declared
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: defining
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: delayed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: dependency
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: deployed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: descendants
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: diagnose
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: diagnostic
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: equitable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: evaluation
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: exclusivity
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: existence
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: existential
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: explicit
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: expressed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: for
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: foreign
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: function
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: identifier
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: implicit
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: indices
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: information
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: instance
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: interchangeable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: interface
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: introduced
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: invalid
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: kind-in
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: least
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: library
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: location
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: namespace
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: necessary
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: nonexistent
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: not
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: number
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: obtains
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: occurs
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: opaque
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: overridden
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: parameter
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: precede
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: preceding
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: property
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: protocol
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: qualified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: recognized
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: recursively
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: references
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: relaxing
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: represented
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: request
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: requirement
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: requirements
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: retrieve
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: returned
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: satisfied
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: satisfy
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: scanner
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: siblings
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: simplified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: something
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: source
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: specializations
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: specially
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: statement
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: stripped
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: structure
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: substitution
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: the
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transform
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transformed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transitively
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transparent
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: typecheck
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unknown
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unlabeled
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unqualified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: whether
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: with
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: scanner
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com >
2022-04-21 12:57:16 -07:00
Slava Pestov
a631d8aa3a
RequirementMachine: Write some comments
2022-03-28 22:16:09 -04:00
Slava Pestov
b90dae1f15
RequirementMachine: Unify every pair of superclass requirements that apply to a term
2022-02-17 19:40:58 -05:00
Slava Pestov
2f16ca38e5
RequirementMachine: Unify every pair of concrete type rules that apply to a term
...
Instead of keeping track of the best one so far, and unifying subsequent rules
against it.
This allows us to record more identities, fixing a regression from an earlier
change where we were unable to eliminate an obviously-redundant rule.
2022-02-17 19:40:58 -05:00
Slava Pestov
86d47d951d
RequirementMachine: Re-visit substitution-simplified rules for concrete unification
2022-02-17 19:40:58 -05:00
Slava Pestov
ef1292e1ce
RequirementMachine: Don't filter out redundant superclass conformances when building archetypes
...
This was a hack to maintain exact compatibility with the GSB's
results when constructing archetypes, but it no longer appears
to be necessary.
2022-02-17 19:40:58 -05:00
Slava Pestov
2e3cb17666
RequirementMachine: Refactor concrete substitution pass
2022-02-15 04:02:46 -05:00
Slava Pestov
e478ced1ce
RequirementMachine: Move some code into a new SimplifySubstitutions.cpp
2022-02-15 04:02:46 -05:00
Slava Pestov
e445335eb3
RequirementMachine: Record rewrite loops during superclass unification
...
This is the second half of rdar://problem/88134910.
Also addresses rdar://problem/25065503.
2022-02-09 22:44:06 -05:00
Slava Pestov
4d1a8dfe23
RequirementMachine: Don't record no-op PrefixSubstitutions rewrite steps
2022-02-09 00:26:04 -05:00
Slava Pestov
00d226fd2f
RequirementMachine: Store the base term in the TypeDifference
2022-02-07 08:20:59 -05:00
Slava Pestov
634ca55764
RequirementMachine: Rework completion limits a bit
...
- Rename StepLimit to MaxRuleCount, DepthLimit to MaxRuleLength
- Rename command line flags to -requirement-machine-max-rule-{count,length}=
- Check limits outside of PropertyMap::buildPropertyMap()
- Simplify the logic in RequirementMachine::computeCompletion()
2022-02-07 08:20:59 -05:00
Slava Pestov
730941b3ea
RequirementMachine: Implement PropertyMap::concretelySimplifyLeftHandSideSubstitutions()
2022-02-07 08:20:58 -05:00
Slava Pestov
a11151a7e3
RequirementMachine: Fix up some comments
2022-02-04 22:49:28 -05:00
Slava Pestov
b138c7602d
RequirementMachine: Add DebugFlags::PropertyMap
2022-02-04 22:47:49 -05:00
Slava Pestov
4f3d05f502
RequirementMachine: Remove Symbol::getSuperclass()
2022-02-04 22:47:19 -05:00
Slava Pestov
106896228e
RequirementMachine: Split up Rule::isSimplified() into three predicates
...
We have three simplification passes, give each one its own predicate:
- Left hand side simplification
- Right hand side simplification
- Substitution simplification
This is for debugging output and will also allow me to tighten up
some invariants.
2022-01-27 18:54:03 -05:00
Slava Pestov
41e3292015
RequirementMachine: Remove 'induced rules' mechanism from the property map
2022-01-25 00:35:11 -05:00
Slava Pestov
ae44028117
RequirementMachine: Allow the property map to record induced rules directly
...
It doesn't actually do this yet, but the idea is to look at the
total rule count before and after, instead of just looking at the
induced rules array (which I will delete in the next commit).
2022-01-25 00:35:11 -05:00
Slava Pestov
8468c14dbc
RequirementMachine: Add overload of PropertyMap::lookUpProperties() that takes a pair of iterators
2022-01-20 12:48:48 -05:00
Slava Pestov
fa30159130
RequirementMachine: Move term to type methods from RewriteContext to PropertyMap
2022-01-20 00:18:47 -05:00
Slava Pestov
f674ca95bd
RequirementMachine: Remove the older 'concrete type in domain' hack
2022-01-11 21:43:56 -05:00
Slava Pestov
56450af673
RequirementMachine: Record identity conformances in the property map
2022-01-11 21:43:55 -05:00
Slava Pestov
9bb497c866
RequirementMachine: Concrete class requirements imply superclass requirements
2022-01-05 22:41:03 -05:00
Slava Pestov
5ced0f8c2e
RequirementMachine: Avoid some wasted work when re-building the property map
2022-01-05 22:41:03 -05:00
Slava Pestov
380dba1a9f
RequirementMachine: Fold PropertyBag::addProperty() into PropertyMap::addProperty()
2022-01-05 22:41:03 -05:00
Slava Pestov
66cf913d68
RequirementMachine: Minimization understands 'relations' among layout requirements
...
A superclass requirement 'T : C' implies a layout requirement
'T : AnyObject' (if the class is @objc) or 'T : _NativeObject'
(if the class is not @objc).
In the latter case, there might already be a 'T : AnyObject'
requirement, in which case the type parameter 'T' is subject
to two layout requirements:
T : AnyObject
T : _NativeObject
The second requirement implies the first however. To encode this
in the world of rewrite loops, we the notion of a 'relation'
between property symbols, and a 'Relation' rewrite step.
Here, the relation is that _NativeObject < AnyObject. Once this
relation is recorded, the Relation rewrite step will transform
T.[layout: _NativeObject].[layout: AnyObject]
into
T.[layout: _NativeObject]
and vice versa.
This rewrite step allows us to construct a rewrite loop which
makes the first rewrite rule redundant via the second.
2022-01-04 22:35:58 -05:00
Slava Pestov
5c11f36354
RequirementMachine: Mark rules as conflicting more aggressively
2021-12-20 17:59:31 -05:00
Slava Pestov
d25b0db75c
RequirementMachine: Fold recordConcreteConformanceRules() into concretizeNestedTypesFromConcreteParent()
2021-12-13 18:48:48 -05:00
Slava Pestov
7a56ab8c18
RequirementMachine: Mark conflicting rules
...
This isn't quite right, because we really want the longer (more
specific) of the two rules to be conflicting, not the most-recently
added rule.
2021-12-13 18:48:23 -05:00
Slava Pestov
d1cda342ed
RequirementMachine: Property map construction introduces concrete conformance rules
2021-12-07 15:31:47 -05:00
Slava Pestov
2aab4bb773
RequirementMachine: Stub out logic for property map to record rewrite loops
...
For homotopy reduction to properly deal with new rules introduced
while bulding the property map, rewrite loops must be recorded
relating these to existing rules.
2021-12-07 15:31:45 -05:00
Slava Pestov
e9b50f00f2
RequirementMachine: Record property rule IDs in property bags
...
For homotopy reduction to properly deal with rewrite rules
introduced by property map construction, we need to keep
track of the original property rules when recording properties
in property bags.
For now, this doesn't even attempt to handle unification or
conflicts; we only record the first rule for each kind of
property on a fixed key.
This isn't actually used for anything yet, except a new
verify pass that runs after property map construction.
2021-12-06 23:04:46 -05:00
Slava Pestov
5ac83e2819
RequirementMachine: Move buildPropertyMap() from RewriteSystem to PropertyMap
...
Now that the property map stores a reference to the RewriteSystem,
defining the buildPropertyMap() method on PropertyMap feels cleaner,
and allows more of the property map's internals to be private.
2021-11-01 22:51:26 -04:00
Slava Pestov
745acea7ce
RequirementMachine: Introduce Rule::isIdentityConformanceRule()
2021-10-27 00:39:07 -04:00
Slava Pestov
0571b65cb8
RequirementMachine: Move protocol linear order from ProtocolGraph to RewriteContext
2021-10-21 19:00:10 -04:00
Slava Pestov
d00ad536d4
RequirementMachine: Split off PropertyUnification.cpp from PropertyMap.cpp
2021-10-19 18:42:41 -04:00
Slava Pestov
5ea7a06a2b
RequirementMachine: Fix small typos
2021-10-19 18:40:31 -04:00
Slava Pestov
56439726ab
RequirementMachine: Move some code from PropertyMap.cpp to RewriteContext.cpp
2021-10-14 15:03:26 -04:00
Slava Pestov
576845d1c5
RequirementMachine: Tighten up type witness recursion hack
...
When a type parameter is subject to a conformance requirement and a
concrete type requirement, the concrete type unification pass
recursively walks each nested type introduced by the conformance
requirement, and fixes it to the concrete type witness in the
concrete type conformance.
In general, this can produce an infinite sequence of concrete type
requirements. There are a couple of heuristics to "tie off" the
recursion.
One heuristic is that if a nested type of a concrete parent type is
exactly equal to the parent type, a same-type requirement is
introduced between the child and the parent, preventing concrete
type unification from recursing further.
This used to check for exact equality of types, but it is possible
for the type witness to be equal under canonical type equivalence,
but use a different spelling via same-type requirements for some
type parameter appearing in structural position.
Instead, canonicalize terms here, allowing recursion where the
type witness names a different spelling of the same type.
Fixes <rdar://problem/83894546>.
2021-10-10 00:26:14 -04:00
Slava Pestov
8fbe93c469
RequirementMachine: Rename Rule::isDeleted() => isSimplified(), and add isPermanent(), isRedundant() bits
2021-09-24 08:59:51 -04:00
Slava Pestov
1fa36c70c6
RequirementMachine: Factor out Rule::isPropertyRule() from the property map
2021-09-24 08:59:51 -04:00
Slava Pestov
e4f6128990
RequirementMachine: Don't simplify terms inside concrete substitutions when adding a rule
...
The effect of doing this is difficult to represent with homotopy generators,
so let's just not bother.
2021-09-24 08:59:50 -04:00
Slava Pestov
399a600e32
RequirementMachine: Add -debug-requirement-machine= flag to control debug output
2021-08-20 01:29:22 -04:00
Slava Pestov
9738d4eef6
RequirementMachine: PropertyMap can use Terms instead of MutableTerms as keys
...
Also, we don't have to sort rules in term order before adding them to
the map; a bucket sort by term length is sufficient.
2021-08-06 14:17:20 -04:00