Commit Graph

6038 Commits

Author SHA1 Message Date
Kavon Farvardin
f1142d5da4 [nfc] rename or eliminate isPureMoveOnly APIs
I think from SIL's perspective, it should only worry about whether the
type is move-only. That includes MoveOnlyWrapped SILTypes and regular
types that cannot be copied.

Most of the code querying `SILType::isPureMoveOnly` is in SILGen, where
it's very likely that the original AST type is sitting around already.
In such cases, I think it's fine to ask the AST type if it is
noncopyable. The clarity of only asking the ASTType if it's noncopyable
is beneficial, I think.
2023-09-20 15:23:17 -07:00
swift-ci
1b6470ca9c Merge remote-tracking branch 'origin/main' into rebranch 2023-09-20 15:07:15 -07:00
Yuta Saito
c5314bd3af Centralize KeyPath accessor calling convention logic to IRGen
KeyPath's getter/setter/hash/equals functions have their own calling
convention, which receives generic arguments and embedded indices from a
given KeyPath argument buffer.
The convention was previously implemented by:
1. Accepting an argument buffer as an UnsafeRawPointer and casting it to
   indices tuple pointer in SIL.
2. Bind generic arguments info from the given argument buffer while emitting
   prologue in IRGen by creating a new forwarding thunk.

This 2-phase lowering approach was not ideal, as it blocked KeyPath
projection optimization [^1], and also required having a target arch
specific signature lowering logic in SIL-level [^2].

This patch centralizes the KeyPath accessor calling convention logic to
IRGen, by introducing `@convention(keypath_accessor_XXX)` convention in
SIL and lowering it in IRGen. This change unblocks the KeyPath projection
optimization while capturing subscript indices, and also makes it easier
to support WebAssembly target.

[^1]: https://github.com/apple/swift/pull/28799
[^2]: https://forums.swift.org/t/wasm-support/16087/21
2023-09-20 11:25:39 -07:00
Kuba Mracek
a31c3388e4 [embedded] Add a temporary flag that turns throws into traps so that programs that use throwing can at least be compiled for now 2023-09-19 22:00:51 -07:00
swift-ci
d2b176c047 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-19 09:55:18 -07:00
Kavon Farvardin
54e5205194 Merge pull request #68600 from kavon/optional-try-coercion-bug-v2
[SILGen] fix SR-14882: Assertion failed: (!concreteBuffer && "concrete buffer already formed?!")
2023-09-19 09:42:04 -07:00
Kavon Farvardin
583f127de7 fix [SR-14882]: Assertion failed: (!concreteBuffer && "concrete buffer already formed?!")
The problem was that in the by-address emission, we were calling
 `getAddressForInPlaceInitialization` twice, triggering the assert.

The first time in `emitExprInto` for the normal result case.

The second time to obtain the address again when generating the
catch block to inject a `.none` into that same address.

This patch does a light refactoring to more closely mirror
`visitOptionalEvaluationExpr`, which avoids calling the asserting method.

fixes rdar://80277465
2023-09-18 15:41:43 -07:00
swift-ci
48d37e45f5 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-17 13:14:20 -07:00
Holly Borla
549b45250f [Concurrency] Remove ClosureActorIsolation. 2023-09-16 12:22:38 -07:00
Holly Borla
97f1e617fd [Concurrency] Replace ClosureActorIsolation with ActorIsolation throughout
the isolation query APIs.
2023-09-16 12:21:36 -07:00
Holly Borla
4b23564711 [Concurrency] Rename AbstractClosureExpr::getActorIsolation to
getClosureActorIsolation.

This is preparation for changing AbstractClosureExpr to store
ActorIsolation instead of ClosureActorIsolation, and convert to
ClosureActorIsolation when needed to allow incrementally updating
callers. This change is NFC.
2023-09-16 12:20:53 -07:00
swift-ci
4441b37ec8 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-11 15:34:47 -07:00
Alejandro Alonso
93c332bcdd Merge pull request #66768 from Azoy/pack-count-builtin
[AST] Add Builtin.packLength
2023-09-11 15:23:37 -07:00
swift-ci
e72811e31e Merge remote-tracking branch 'origin/main' into rebranch 2023-09-09 10:13:45 -07:00
Holly Borla
e23e4c32f5 Merge pull request #68414 from hborla/nonisolated-init-hole
[Concurrency] Don't allow nonisolated initializers to introduce data races via superclass property observers.
2023-09-09 09:55:24 -07:00
swift-ci
af7aa91358 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-08 19:13:48 -07:00
Slava Pestov
80e43fba14 Merge pull request #68399 from slavapestov/fix-rdar114823719
SILGen: Use the right abstraction pattern when loading 'async let' result
2023-09-08 21:58:40 -04:00
swift-ci
e77b2ee5b0 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-08 18:56:08 -07:00
Pavel Yaskevich
c75aea3654 Merge pull request #68390 from xedin/checked-continuations-for-foreign-callbacks
Provide ability to use CheckedContinuation when suspending for an async ObjC call
2023-09-08 18:52:04 -07:00
Slava Pestov
583c51ae87 SILGen: Use the right abstraction pattern when loading 'async let' result
The payload is stored maximally-abstracted, so make sure we respect
that to avoid a crash when the 'async let' binding has a function type.

Fixes rdar://114823719.
2023-09-08 17:41:42 -04:00
Holly Borla
a6d078b820 [Concurrency] Use the 'nonisolated' terminology instead of 'independent'.
This commit is NFC; it's mostly renames.
2023-09-08 13:28:55 -07:00
Pavel Yaskevich
ce651ca67d [SILGen] ResultPlan: Address a FIXME about resume with foreign error 2023-09-08 10:52:41 -07:00
swift-ci
734d18ac13 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-08 07:14:28 -07:00
nate-chandler
e7783563ce Merge pull request #68285 from nate-chandler/effects-diagnostic
[Diagnostics] Require explicit releasenone.
2023-09-08 07:04:31 -07:00
Pavel Yaskevich
6ecbb088b9 [SILGen] ResultPlan: Add a FIXME about foreign error bridging in checking continuations mode 2023-09-07 17:52:22 -07:00
Pavel Yaskevich
4b22620d11 [SILGen] Implement async completion bridging via checked continuations
Because `CheckedContinuation` is not a @frozen struct we have
to use `Any` to store it in @block_storage indirectly. If the
flag is enabled, we'd emit a block storage with `Any` and
initialize the existential with stack allocated `CheckedContinuation`
formed from `UnsafeContinuation`. Inside of the completion handler
`Any` is going to be projected and cast back to `CheckedContinuation`.
2023-09-07 17:35:38 -07:00
Pavel Yaskevich
6e48d449e8 [SILGen] NFC: Introduce intrinsics for construction and resumption of CheckedContinuation 2023-09-07 17:35:38 -07:00
Pavel Yaskevich
a6025310a3 [SILGen] Pass storage block type and callee info to async completion handler generator
Instead of relying on `continuationType` for information, let's
take it from the source.
2023-09-07 17:35:07 -07:00
Alejandro Alonso
ff6bd36aa8 Add Builtin.packLength
Simplify packCount IRGen

Emit pack_length instruction

Add space
2023-09-07 15:36:14 -07:00
Nate Chandler
63bdb4ab1f [Gardening] Fixed variable name.
In SILGen, it's an SGM not an IGM.
2023-09-05 08:18:02 -07:00
swift-ci
225162a30f Merge remote-tracking branch 'origin/main' into rebranch 2023-09-01 14:36:50 -07:00
Hamish Knight
8dc55b8269 Merge pull request #67454 from hamishknight/then 2023-09-01 22:32:46 +01:00
swift-ci
dbe6df083f Merge remote-tracking branch 'origin/main' into rebranch 2023-09-01 09:13:39 -07:00
Hamish Knight
6ee44f09b4 Introduce then statements
These allow multi-statement `if`/`switch` expression
branches that can produce a value at the end by
saying `then <expr>`. This is gated behind
`-enable-experimental-feature ThenStatements`
pending evolution discussion.
2023-09-01 14:32:14 +01:00
Manu
02b5fa2c8e Fix some typos in the codebase 2023-08-31 18:50:10 -03:00
Sophia Poirier
86d368f364 Merge remote-tracking branch 'upstream/main' into fix-rebranch-automerger 2023-08-31 14:10:52 -07:00
Michael Gottesman
ba06693745 Merge pull request #68228 from gottesmm/pr-088dba5d9c0854c0e00da0603eb99b770d99709c
[move-only] Rename mark_must_check -> mark_unresolved_non_copyable_value
2023-08-31 09:50:55 -07:00
swift-ci
39b640ce1b Merge remote-tracking branch 'origin/main' into rebranch 2023-08-31 09:05:17 -07:00
Slava Pestov
d2f1dedd35 Merge pull request #68220 from slavapestov/remove-get-protocol-self-type
Remove DeclContext::getSelfProtocolType()
2023-08-31 11:39:17 -04:00
Michael Gottesman
37d60a08bb [move-only] Rename mark_must_check -> mark_unresolved_non_copyable_value.
I was originally hoping to reuse mark_must_check for multiple types of checkers.
In practice, this is not what happened... so giving it a name specifically to do
with non copyable types makes more sense and makes the code clearer.

Just a pure rename.
2023-08-30 22:29:30 -07:00
Slava Pestov
361d49a843 AST: Remove DeclContext::getSelfProtocolType() 2023-08-30 15:15:08 -04:00
swift-ci
5917128695 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-29 21:13:49 -07:00
John McCall
804eac63f2 Merge pull request #68191 from rjmccall/wip2-variadic-arg-translation
More progress towards variadic-tuple argument reabstraction
2023-08-29 23:57:16 -04:00
John McCall
acece4c35f [NFC] Push cleanup management through a few reabstraction utilities 2023-08-29 18:11:08 -04:00
John McCall
bdaada6c55 Add a utility to generate a known-trivial load 2023-08-29 14:23:28 -04:00
swift-ci
27c3fe527c Merge remote-tracking branch 'origin/main' into rebranch 2023-08-29 09:33:49 -07:00
Pavel Yaskevich
e96f9e5b33 [SILGen] InitAccessors: Materialize default argument if it's required by init/setter
We do this in `GetterSetterComponent` but overlooked it for default initialization
expressions. If init/setter require `newValue` to be passed indirectly we have to
make sure to materialize it before handing to `assign_or_init` instruction.

Resolves: rdar://114350227
2023-08-28 17:04:53 -07:00
swift-ci
0b0bb0b8b7 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-28 09:55:22 -07:00
Pavel Yaskevich
fce0d33714 Merge pull request #68155 from xedin/issue-67827
[SILGen] InitAccessors: Make sure that `assign_or_init` always directly references self
2023-08-28 09:36:53 -07:00
John McCall
60d2a93209 [NFC] result -> inner, for consistency 2023-08-28 12:27:36 -04:00