Commit Graph

2441 Commits

Author SHA1 Message Date
nate-chandler
f009071d42 Merge pull request #64649 from nate-chandler/rdar107283101
[TypeLowering] NFC: Fix lexicality check for packs.
2023-03-28 07:03:39 -07:00
Konrad `ktoso` Malawski
0586c14b60 [Concurrency] SerialExecutor.isSameExclusiveExecutionContext (#64604) 2023-03-28 15:56:28 +09:00
John McCall
08a921198a Assert that we don't produce a SILFunction with a type with opened
type parameters.
2023-03-27 18:31:08 -04:00
John McCall
8421669a59 Pass down the substitutions of the original pattern when extracting
a subst abstraction pattern from a generic nominal type.
2023-03-27 18:31:08 -04:00
John McCall
280c91a54f Fix the dumping of AbstractionPatterns with substitutions 2023-03-27 18:31:08 -04:00
Nate Chandler
adb21a373a [TypeLowering] Fix lexicality check for packs.
In asserts builds, the lexicality of packs is verified via an
alternative code-path that walks into aggregates.  That walk needs to
proceed through packs.

rdar://107283101
2023-03-27 14:03:30 -07:00
Allan Shortlidge
ada0f09615 SILGen: Implement 'complete' unavailable decl optimization.
Avoid SIL lowering for declarations marked unavailable when
`-unavailable-decl-optimiation=complete` is specified.

Part of rdar://106674022
2023-03-27 11:40:54 -07:00
John McCall
c041d1061a Perform component-wise substitution of pack expansions immediately.
Substitution of a pack expansion type may now produce a pack type.
We immediately expand that pack when transforming a tuple, a function
parameter, or a pack.

I had to duplicate the component-wise transformation logic in the
simplifyType transform, which I'm not pleased about, but a little
code duplication seemed a lot better than trying to unify the code
in two very different places.

I think we're very close to being able to assert that pack expansion
shapes are either pack archetypes or pack parameters; unfortunately,
the pack matchers intentionally produce expansions of packs, and I
didn't want to add that to an already-large patch.
2023-03-26 04:12:59 -04:00
John McCall
3b3e53eb73 [NFC] Use InFlightSubstitution in the SIL type substituter 2023-03-25 18:54:14 -04:00
John McCall
06b5c97256 [NFC] Split the SIL type substitution code into its own file 2023-03-25 18:54:14 -04:00
Adrian Prantl
c5efebe784 Preserve the Implicit attribute in SILLocation. (NFC)
This change aims at reducing the need for SIL passes to check into the AST
storage of SILLocations. The end goal is to eventually merge this with the
autogenerated flag, but at the moment the emergent semantics of both properties
are not identical.
2023-03-23 14:59:05 -07:00
John McCall
debc8d9ebd [NFC] Move forEachTupleElement to use a generator 2023-03-22 22:04:36 -04:00
Adrian Prantl
63304d0787 SILLocation: Move pointsToEnd flag into ASTNodeTy. NFC
The pointsToEnd flag is only meaningful when combined with an AST node, and
moving it into the AST pointer frees up a bit in the flags bitfield for later
use.
2023-03-22 14:04:28 -07:00
John McCall
0c3c62bd73 [NFC] Rename isPackExpansion -> isOrigPackExpansion for clarity 2023-03-22 15:40:02 -04:00
John McCall
9fbecde9a0 Do proper parallel walks of orig+subst types when computing type
properties for struct and enum types.
2023-03-22 15:40:02 -04:00
John McCall
a0eeabc886 When computing the field type of a SILType, add substitutions to the orig type. 2023-03-22 15:40:02 -04:00
John McCall
8ff61d6a54 When we are performing SIL substitution, and we reach a type that
needs to be lowered, use an opaque abstraction pattern.

As I argue in the comment, we know that the orig type is now either
an opaque type or a type with high-level structure that is invariant
to lowering.  Substitution will not change the latter property, and
an opaque abstraction pattern is correct for the former.  Attempting
to create a "truer" abstraction pattern that preserves more structure
from the orig type is both pointless and problematic.  The
substitutions we just did may have replaced pack references with
non-pack types if there are active expansions in progress; this cannot
be easily explained in terms of substitutions.  (In theory, we could
pass a more opaque concept of substitutions through AbstractionPattern,
which might help with this.  That would also make it harder to catch
bugs with signature mismatches, though.)
2023-03-22 15:40:02 -04:00
John McCall
f99efc2f94 Fix unsafeGetSubstFieldType to propagate a substitution map in
whichever case it happens to be in.

This is a basic fix so that parallel walks on tuples and function
types in the substituted type will work .  Separately, though, I
do not think the places that use this really need to be passed an
orig type; this is used for computing type properties, and I am
not aware of any reason we should need an orig type to compute
type properties.  Additionally, the orig types computed by this
function are not really correct because of the substitution being
done in some cases, so it'd be very nice to rip this all out.
I'm not good to look into that right now, though.
2023-03-22 15:40:02 -04:00
John McCall
bbc682822a [NFC] Change the printing of AbstractionPattern to include the sub map 2023-03-22 15:40:02 -04:00
John McCall
7505a8a487 Merge pull request #64517 from rjmccall/arity-reabstraction-closures
Implement arity reabstraction for closures
2023-03-22 14:14:23 -04:00
John McCall
5cf05f501b Implement arity reabstraction for closures 2023-03-21 22:23:45 -04:00
Konrad `ktoso` Malawski
345c221f56 [Concurrency] Distributed actor's unownedExecutor should be optional (#64499) 2023-03-22 08:40:41 +09:00
Adrian Prantl
5129aea296 Add a verify-di-hole assertion to SILBuilder.
The verify-di-hole SILVerifier pass is very useful in catching incorrectly set
SILDebugScopes, but it can be very tedious to track down the root cause of a
verification failure. This patch replicates much of its functionality inside an
assertion in SILBuilder, which will result in a backtrace pointing directly to
where the offending scope is being set.
2023-03-21 09:40:11 -07:00
Erik Eckstein
a092ecb5c2 remove SILBridgingUtils.h 2023-03-21 15:33:09 +01:00
Erik Eckstein
04c90166c4 Swift Bridging: use C++ instead of C bridging for BridgedBuilder 2023-03-21 15:33:09 +01:00
Erik Eckstein
7905a9ac64 Swift Bridging: remove C bridging functions for SILDebugLocation 2023-03-21 15:33:09 +01:00
Erik Eckstein
8c05024ea6 SIL: move the SILInstruction::MemoryBehavior enum out of SILInstruction into the swift namespace 2023-03-21 15:33:09 +01:00
Erik Eckstein
ae7770d911 Swift Bridging: use C++ instead of C bridging for BridgedFunction 2023-03-21 15:33:09 +01:00
Erik Eckstein
e469c16744 Swift Bridging: remove BridgedType and directly use the C++ SILType instead 2023-03-21 15:33:09 +01:00
John McCall
78996db4ab Merge pull request #64476 from rjmccall/arity-reabstraction
Implement parameter arity reabstraction
2023-03-21 01:27:07 -04:00
John McCall
5f1a669f2f [NFC] Change the existing client of forEachFunctionParam
Yeah, this is much cleaner.
2023-03-20 16:01:54 -04:00
John McCall
2e4ad65889 [NFC] Change forEachFunctionParam to only ignore the final orig parameter
and not also drop a subst parameter.

This turned out to be more convenient for certain clients (e.g. SILGenPoly)
than requiring the full subst param list to be passed in.  These clients
want to process the subst param list separately, and dropping self early
can be convenient for that.  The only fundamental reason we need this
flag is for working with the orig type, so just use it for that; clients
that need to use this feature can reasonably be expected to cooperate.
2023-03-20 13:36:40 -04:00
John McCall
2172c0ae52 [NFC] Provide a more generator-like interface for traversing orig+subst function parameters
This is necessary because the use patterns in SILGenPoly require
walking two orig+subst sequences in parallel, which poses problems
for a callback-centric design like the one I addded before.  An
inversion of control is necessary; this is basically a manual
coroutine.  But frankly it's a nicer interface than the callback
design, too; I switched the implementation of forEachFunctionParam
to use the generator just to avoid code duplication, but I might
try to remove it and switch all the clients over to the generator.
The main problems with the callback design are that (1) I wasn't
sure which values clients would want, and the result is that there
are a *lot* of parameters and (2) (relatedly) the types of those
parameters have to be written out explicitly, and some of them
are quite large.  The generator code is just much nicer.  Maybe
I can still give the generator a little unparameterized callback
to keep lexical loops simple.

I'll need to do this same thing for tuples.  One at a time.
2023-03-20 13:36:40 -04:00
Michael Gottesman
ee451f0862 [move-only] If we have a noncopyable type on an alloc_stack/alloc_box/debug_value, set the [moveable_value_debuginfo] flag.
This still does not have the complete behavior that we want since we are not yet
inserting the debug_value undef to invalidate after performing moves.

NOTE: In printed SIL, I decided to make the flag implicit if we have a
noncopyable type. This is just to reduce the bloat in SIL. If one needs this
property for a copyable type though, it is mandatory.
2023-03-19 16:05:51 -07:00
Michael Gottesman
8d12f893c2 [sil] Add a moveable_value_debuginfo field to AllocBoxInst.
Just getting parsing/serialization to work. I haven't wired it up to anything.
2023-03-19 15:50:29 -07:00
Michael Gottesman
1a76f8f271 [sil] Move alloc_box flags to SharedUInt8. 2023-03-19 15:39:01 -07:00
Michael Gottesman
4a309575d7 [sil] Rename [moved] flag on debug_value/alloc_stack to moveable_value_debuginfo.
This is in preparation for wiring up debug info support for noncopyable
values. Originally this flag name made sense since it was set when we performed
consume operator checking. Now I am going to use it for noncopyable types as
well. I think the new name uses_moveable_value_debuginfo actually describes what
the flag is supposed to do, tell IRGen that the value may be moved since it
needs to use moveable value debug info emission.
2023-03-19 15:38:42 -07:00
Alex Lorenz
cf0763dc87 [interop] Swift -> C++ -> Swift class type bridging 2023-03-18 19:29:55 -07:00
John McCall
4d5f0906e0 Fix the computation of thunk types for functions involving element archetypes
The old code assumed that thunk signatures would only possibly refer to a
single opened existential archetype.  To generalize this to opened element
archetypes, it needs to both support multiple archetypes and, of course,
support the new kind of local archetype.  So here's a bunch of code to
clone element signatures and support multiple local archetypes.  It fell out
to also make this support multiple opened existential archetypes, if we
ever have code patterns that require that.
2023-03-17 22:07:11 -04:00
John McCall
3342d67161 Fix the creation of substituted abstraction patterns for expansions 2023-03-17 22:07:10 -04:00
John McCall
e1c3988dad Fix the SIL substitution of SubstitutionMaps to respect expansions 2023-03-17 15:41:37 -04:00
John McCall
72cc8dcb1e [NFC] Rewrite the subst-type extracttor to be a CanTypeVisitor 2023-03-16 15:56:46 -04:00
John McCall
f3e7daf478 [NFC] Remove the now-dead PackExpanded accessors from AbstractionPattern 2023-03-16 01:38:46 -04:00
John McCall
4499e3d055 [NFC] Introduce new APIs for traversing orig/subst parameters in parallel 2023-03-16 01:38:46 -04:00
John McCall
d524c7d230 Use correct parallel destructuring when lowering tuple types. 2023-03-16 00:19:31 -04:00
John McCall
9ab4dc494c [NFC] Add better APIs for parallel destructuring of orig+subst types
As I've been iterating on this work, I've been gradually mulling these
over, and I think this is the way to go for now.  These should make it
a lot less cumbersome to write these kinds of traversals correctly.

The intent is to the sunset the existing expanded-components stuff
after I do a similar pass for function parameters.
2023-03-16 00:19:30 -04:00
John McCall
09018a8981 [NFC] Store interface shape types in opened element environments 2023-03-15 17:25:04 -04:00
Slava Pestov
151e1c55be Merge pull request #64337 from slavapestov/misc-variadic-generic-fixes
Miscellaneous variadic generics fixes
2023-03-15 14:53:25 -04:00
Slava Pestov
c3a6bfb5bc SIL: Implement SILTypeSubstituter::hasSameShape() 2023-03-15 11:59:47 -04:00
Slava Pestov
783d9987f2 SIL: Introduce SameShape requirements in SubstFunctionTypePatternVisitor 2023-03-15 11:59:47 -04:00