Commit Graph

1309 Commits

Author SHA1 Message Date
Pavel Yaskevich b79a051797 [Concurrency] NFC: Rename FunctionTypeIsolation::forIsolatedCaller into forNonisolatedNonsending
Previous refactoring missed this method when the `FunctionTypeIsolation::Kind`
was renamed to `NonisolatedNonsending`.
2026-05-05 09:57:40 -07:00
Meghana Gupta 769c593658 Merge pull request #88729 from meg-gupta/borrowsilgenbug1
Fix call emission of borrow accessors on class let properties
2026-04-30 11:58:16 -07:00
Andrew Trick 645e2dc3ba Merge pull request #88699 from blevine1/pr-175724267-consuming-accessor-resilient-base
[SILGen] Mark +0 base unresolved for consuming accessor
2026-04-30 10:25:10 -07:00
Meghana Gupta 9f0f92104e Fix call emission of borrow accessors on class let properties
In `applyBorrowMutateAccessor()`, the self value was not being passed
to `getFnValue()` for class method dispatch. Fix this by correctly passing
the self value when it is required for dispatch similar to the call emission
of other accessors.
2026-04-28 21:12:18 -07:00
Benjamin Levine 5c5723c557 formatting and fix test note 2026-04-28 13:48:00 -04:00
Benjamin Levine 86999bd9bd avoid duplicate mark_unresolved_non_copyable_value instructions 2026-04-28 13:12:47 -04:00
Konrad Malawski a6617f8801 rename isNonisolatedNonsendingCaller -> isNonisolatedNonsending 2026-04-28 09:21:46 -07:00
Konrad Malawski 2b8026dd94 rename isNonIsolatedCaller -> isNonisolatedNonsendingCaller 2026-04-28 09:21:46 -07:00
Konrad Malawski 003028c17c more rename followups for isNonisolated and the enum change 2026-04-28 09:21:23 -07:00
Konrad Malawski 77ac31d946 Rename to ActorIsolation::Kind::Nonisolated*Concurrent* 2026-04-28 09:21:23 -07:00
Konrad Malawski 3beefe5bd8 Rename CallerIsolationInheriting -> NonisolatedNonsending 2026-04-28 09:21:23 -07:00
Benjamin Levine 4640b58e99 [SILGen] Mark +0 base unresolved for consuming accessor 2026-04-28 02:22:36 -04:00
Andrew Trick c73baf80dd [SILGen] diagnose invalid Builtin.borrowAt usage. 2026-04-23 10:47:43 -07:00
Elsa Keirouz 85671a9599 fix: handle addressable OpaqueValueExprs in SILGen 2026-03-25 09:51:54 +00:00
Kavon Farvardin 0283179142 Merge pull request #86815 from jamieQ/nothrow-to-throws-never-accessor-fix
[SILGen]: some fixes for throws(Never) properties & subscripts
2026-03-23 13:42:27 -07:00
Jamie 9b4dd2add2 [SILGen]: some fixes for throws(Never) properties & subscripts 2026-03-21 10:17:17 -05:00
John McCall bf851fa4dd Model the stack allocation effects of {add,remove}TaskLocalValue.
The biggest complexity here is dealing with the improper nesting of the
allocation for the argument, and I'm not very proud of the solution I found,
but for a one-off builtin, I think it'll work.
2026-03-20 00:21:40 -04:00
Kavon Farvardin 606930c649 Merge pull request #86619 from jamieQ/typed-throws-never-thunk-crash
[SILGen]: fix thunk emission for nothrow to throws(Never)
2026-03-19 08:46:59 -07:00
Pavel Yaskevich 11fbfd5da5 [Concurrency] SE-0434: Member types should get @Sendable together with global-actor isolation
Previously an inner type only got the isolation but not `@Sendable`
when `GlobalActorIsolatedTypesUsability` is enabled, this is incorrect
because with the feature enabled global-actor isolation always implies
`@Sendable` for functions and closures.

Resolves: rdar://problem/171967902
2026-03-09 17:24:59 -07:00
Gábor Horváth 88a9d748ca Merge pull request #86421 from Xazax-hun/bridge-intrusive-ptrs 2026-01-30 19:16:29 +00:00
Gabor Horvath 96ee6eaf18 [cxx-interop] Implicitly bridge annotated smart pointers to reference types
This PR introduces implicit bridging from annotated smart pointers to
reference counted objects to Swift foreign reference types. The bridging
only happens when these smart pointers are passed around by value. The
frontend only sees the Swift foreign reference types in the signature
and the actual bridging happens during SILGen when we look at the
original clang types and note that they differ significantly from the
native types.

The bridging of parameters did not quite fit into the existing structure
of bridging conversions as smart pointers are non-trivial types passed
around as addresses and existing bridging conversions were implemented
for types passed directly.

rdar://156521316
2026-01-28 12:34:21 +00:00
Joe Groff 0f3ddfbcc8 Merge pull request #86545 from jckarter/builtin-borrow
`Builtin.Borrow` implementation
2026-01-26 07:32:31 -08:00
elsa 5e9f215f31 Merge pull request #86010 from elsakeirouz/rework-for-each-desugar
Rework ForEachStmt Desugaring
2026-01-24 13:55:51 +00:00
Tim Kientzle 7e32732649 [SE-0474] Force unwind off for new yielding accessors
In the context of coroutine/yielding accessors, "unwind" means
that the second half of the coroutine (code _after_ the `yield`
statement) will not run if an exception is thrown during the access.

Unwinding was the default behavor for legacy `_read`/`_modify` coroutine
accessors.
For the new `yielding borrow`/`yielding mutate` accessors, unwinding
was optional behind a separate feature flag.
But the final SE-0474 dictates that unwinding is always _disabled_ for
the new yielding accessors.  That is, the new yielding accessors always
run to completion, regardless of whether there are thrown exceptions within
the access scope.  This was deemed essential to ensure that authors of
data structures could guarantee consistency.

This PR permanently disables unwinding behavior for the new accessors.
The feature flag still exists but has no effect.
A handful of tests that verified the unwinding behavior have been
edited to ensure that unwinding does _not_ happen even when the feature
flag is specified.
2026-01-23 16:01:48 -08:00
Joe Groff 3d543f545e SILGen: Lowering for Builtin.dereferenceBorrow.
This builtin only needs to be supported as the return of a borrow accessor,
so special case its handling as part of a storage expression in SILGenLValue.
2026-01-23 08:02:08 -08:00
Elsa Keirouz d54a572f7f [Sema] desugar ForEachStmt at AST level 2026-01-23 15:17:29 +00:00
Elsa Keirouz 27cef65d56 [AST] Introduce opaque AST nodes 2026-01-23 15:17:28 +00:00
Jamie 8e00755a07 [SILGen]: fix thunk emission for nothrow to throws(Never)
Previously attempting to emit a thunk to wrap a throws(Never) function
within a non-throwing function would crash during SILGen because it was
unconditionally assumed the outer function had an error result. Change
this so that such cases instead create a try_apply and error branch as
they did before, but replace the rethrowing logic in the error branch
with an unreachable instruction.
2026-01-21 06:44:01 -06:00
Tim Kientzle 8eabeeb8ca [SE-0474] Read2/Modify2 => YieldingBorrow/YieldingMutate
This updates a large number of internal symbols, function names,
and types to match the final approved terminology.  Matching the
surface language terminology and the compiler internals should
make the code easier for people to understand into the future.
2026-01-03 16:05:12 -08:00
Slava Pestov 783e1e104c SILGen: Fix edge case where we didn't erase opaque result type in constructor
- Fixes https://github.com/swiftlang/swift/issues/68298.
- Fixes https://github.com/swiftlang/swift/issues/68277.
2025-12-20 16:22:07 -05:00
Meghana Gupta 6f7d420f9d Fix unchecked_conversion insertion for borrow accessors 2025-12-12 11:38:26 -08:00
Adrian Prantl 0e55f81931 Merge pull request #66580 from adrian-prantl/110333983
Make source locations for standard library calls explicit
2025-12-02 08:56:32 -08:00
Slava Pestov 819738c83e AST: Rename mapTypeIntoContext() => mapTypeIntoEnvironment(), mapTypeOutOfContext() => mapTypeOutOfEnvironment() 2025-11-12 14:48:19 -05:00
Hamish Knight 90bc9a12c7 [SILGen] Add assert to emitApplyAllocatingInitializer
Make sure we reliably assert in release builds if `getBuiltinInitDecl`
passes a null value here.
2025-11-11 15:58:24 +00:00
Slava Pestov 522a6b7c80 SILGen: Fix break/continue inside 'for ... in ... repeat' loop
We were creating the JumpDests too early, so lowering a 'break' or 'continue'
statement would perform cleanups that were recorded while evaluating the
pack expansion expression, which would cause SIL verifier errors and
runtime crashes.

- Fixes https://github.com/swiftlang/swift/issues/78598
- Fixes rdar://131847933
2025-11-10 20:51:45 -05:00
Meghana Gupta 290d2f00a3 Fix mark_unresolved_noncopyable_value instruction introduced for mutate accessor result 2025-11-06 10:55:43 -08:00
Meghana Gupta d50aa8ad87 [NFC] Comment on the use of unchecked_ownership 2025-11-06 10:55:41 -08:00
John McCall a7d7970e29 Turn finishAsyncLet into a builtin.
This is necessary because we need to model its stack-allocation
behavior, although I'm not yet doing that in this patch because
StackNesting first needs to be taught to not try to move the
deallocation.

I'm not convinced that `async let` *should* be doing a stack allocation,
but it undoubtedly *is* doing a stack allocation, and until we have an
alternative to that, we will need to model it properly.
2025-11-03 16:33:40 -08:00
John McCall 1d95fe14de Remove the deprecated and unused startAsyncLet builtin 2025-11-03 13:44:58 -08:00
Slava Pestov 4677512a74 Merge pull request #84664 from jamieQ/fix-iso-default-param-idx-bug
[SILGen]: fix a bug in isolated default argument handling
2025-10-30 03:40:49 -04:00
Meghana Gupta bef207521d Use unchecked_ownership during SILGen of borrow accessors 2025-10-23 05:19:10 -07:00
Meghana Gupta a150c67896 Remove unchecked_ownership_conversion from borrow accessor silgen 2025-10-23 05:19:04 -07:00
Meghana Gupta a0c939bd3b Use @inout result convention for mutate accessors 2025-10-20 09:05:32 -07:00
Michael Gottesman 390afe3e7d [concurrency] Implement bit masking for TBI when available or in tagged pointer bits otherwise.
Specifically, when TBI is available we use the bottom two bits of the top nibble
(bits 60,61). On platforms without TBI, we use the bottom two tagged pointer
bits (bits 0, 1).

rdar://156525771
2025-10-16 10:52:05 -07:00
Michael Gottesman 788abd0b96 [silgen] Use Builtin.ImplicitActor instead of Optional<any Actor> to represent the implicit isolated parameter.
NOTE: We are not performing any bitmasking at all now. This is so that we can
transition the code base/tests to expect Builtin.ImplicitActor instead
of Optional<any Actor>.

NOTE: The actual test changes are in the next commit. I did this to make it
easier to review the changes.

This should not have any user visible changes.
2025-10-16 10:52:05 -07:00
Erik Eckstein 3309809429 SILGen: improve code generation for array literals
It used to be done with a library intrinsic which returns the array and an element address pointer.
A `mark_dependence` was used to "connect" the two results.
But this resulted in completely wrong OSSA after inlining.
It just didn't get caught be the verifier because the SIL was obfuscated by address-pointer conversions.

Now we don't use the second result (= the element address) of the intrinsic but generate a correct borrow scope from the first (= array) result. Within that borrow scope we project out the element address with a `ref_tail_addr` instruction.

This relies on knowledge of the internal Array data structures. However those data structures are baked into the ABI since a long time and will not change.
2025-10-10 14:20:36 +02:00
Kavon Farvardin a528c5c19c Merge pull request #84734 from kavon/opaque-values/fixes-2
OpaqueValues: support typed throws
2025-10-08 21:17:23 -07:00
Meghana Gupta 5e325632ed Merge pull request #84746 from meg-gupta/mutateaccessorspr
Add support for mutate accessors
2025-10-08 11:08:59 -07:00
Gábor Horváth 0959bce25e Merge pull request #84612 from swiftlang/fix-overrelease-destroy-hoist
[cxx-interop] Delay lowering unowned convention until ownership elimination
2025-10-08 18:42:02 +01:00
Meghana Gupta 282e3351f6 Handle mutate accessors similar to borrow accessors in call emission 2025-10-07 14:12:11 -07:00