Commit Graph

16 Commits

Author SHA1 Message Date
John McCall
b099009df6 Be sure to clear @isolated(any) from the constant function type.
I'm not completely sure why this code pattern triggers this --- or really,
why other code patterns don't --- but it's easy to fix.

Fixes rdar://142636640
2025-02-07 17:12:19 -05:00
Erik Eckstein
7cceaff5f3 SIL: don't print operand types in textual SIL
Type annotations for instruction operands are omitted, e.g.

```
  %3 = struct $S(%1, %2)
```

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:

* if the block with the definition appears after the block where the operand's instruction is located

* if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
2024-11-21 18:49:52 +01:00
Allan Shortlidge
cb578172ea Tests: Remove -disable-availability-checking in more tests that use concurrency.
Use the `%target-swift-5.1-abi-triple` substitution to compile the tests for
deployment to the minimum OS versions required for use of _Concurrency APIs,
instead of disabling availability checking.
2024-10-19 12:35:20 -07:00
Holly Borla
966269d31a [Features] Promote IsolatedAny and its alias to a language feature.
The proposal is accepted and implemented for Swift 6.0.
2024-06-18 22:09:16 -07:00
Holly Borla
8d6f16ef4b [Concurrency] @isolated(any) does not imply @Sendable. 2024-05-24 12:22:01 -07:00
John McCall
e7765ad090 Map the isolated variable type into context correctly.
The fix for #72484 didn't properly handle the case of a "generic" context
where all the type parameters had concrete assignments.  In this situation,
F.mapTypeIntoContext does not work because the function has no generic
environment.

Fixes rdar://126085573
2024-04-16 19:31:38 -04:00
John McCall
a040df9aa8 Teach optional injection to peephole into more converting contexts
This allows us to propagate abstraction patterns from optional parameters
all the way to closure emission, which optimizes some code patterns but
(more importantly) propagates our knowledge that we're converting to an
`@isolated(any)` function type down to closure emission, allowing us to
set the isolation correctly.

There are still some conversion cases missing --- if we can't combine
conversions for whatever reason, we should at least shift our knowledge
that we need to produce an `@isolated(any)` type down, the same way that
we shift it when emitting a closure that we can't directly emit in the
target abstraction pattern.  But this completes the obvious cases of
peepholing for closure emission.
2024-03-22 01:19:29 -04:00
John McCall
fb246d4111 Another prospective fix to this test.
I still don't understand *why* this varies by target, but apparently it
involves borrowing MainActor.
2024-03-19 22:06:45 -04:00
John McCall
67939a4074 Make this test case more resilient.
I'm actually not sure why this is different on different targets, but
checking for a single-character binding was inadvertent anyway, so...
2024-03-18 02:44:32 -04:00
John McCall
590643ce5e Make @isolated(any) imply @Sendable. No avoidance mechanism for now. 2024-03-15 00:40:54 -04:00
Holly Borla
f5e407ea30 [Concurrency] Add basic tests for function isolation extraction. 2024-03-13 22:43:10 -07:00
John McCall
43b9b28797 Fix a pair of bugs with @isolated(any) closure erasure.
First, and I really should've checked this, but global actors do not
require `shared` to return `Self`; adjust the logic to propagate the
right formal type to the erasure logic.

Second, handle attempts to erase the isolation of something isolated to
a distributed actor using the magic Actor conformance that Doug added.
This only works when the actor is local, but it shouldn't be difficult to
enforce that we only attempt to erase isolation what that's true --- we
need to prevent partial application of distributed actors, and we need to
disallow explicit isolated captures of distributed actors when we're not
currently isolated to it.  Otherwise, it's not possible to get an
@isolated(any) function value with an isolation that isn't the current
function's isolation, which means it always has to be local.

Fixed rdar://123734019
2024-03-04 04:15:21 -05:00
Michael Gottesman
031564a622 Update some SILGen tests since we now print @sil_isolated. 2024-03-01 14:09:45 -08:00
John McCall
7b3415aa23 Properly erase closure isolation to @isolated(any).
We do this by pushing the conversion down to the emission of the
closure expression, then teaching closure emission to apply the isolation
to the closure.  Ideally, we combine the isolation along with the rest of
the conversion peephole, but if necessary, we make sure we emit the
isolation.
2024-02-26 22:50:58 -05:00
Daniel Rodríguez Troitiño
2db917e4c1 [test] Mark IsolatedAny tests are requiring asserts compiler (#71875)
IsolatedAny is an experimental feature, so the tests require an asserts
compiler to pass.
2024-02-26 13:52:29 -08:00
John McCall
868fc6ad46 Basic SILGen for @isolated(any).
The main piece that's still missing here is support for closures;
they actually mostly work, but they infer the wrong isolation for
actor-isolated closures (it's not expressed in the type, so obviously
they're non-isolated), so it's not really functional.  We also have
a significant problem where reabstraction thunks collide incorrectly
because we don't mangle (or represent!) formal isolation into
SILFunctionType; that's another follow-up.  Otherwise, I think SILGen
is working.
2024-02-19 21:21:03 -05:00