Commit Graph

32 Commits

Author SHA1 Message Date
Daniel Rodríguez Troitiño
ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00
Allan Shortlidge
c02fc4724d Tests: Remove -disable-availability-checking from many Concurrency tests.
Instead, 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.
2024-10-18 16:21:51 -07:00
Holly Borla
1a07152ee0 [NFC][Concurrency] Remove -disable-region-based-isolation-with-strict-concurrency
from tests.
2024-06-19 20:48:59 -07:00
Michael Gottesman
0e21c58619 [region-isolation] Disconnected regions in global actor isolated function are not accessible again after call to nonisolated async function
I also fixed the nonisolated(unsafe) issue.

rdar://126667934
rdar://126174959
2024-04-19 13:52:58 -07:00
Michael Gottesman
a56d0f5ded [region-isolation] Tweak the main transferring diagnostic.
Specifically, I am transforming it from "may cause a race" -> "may cause a data
race". Adding data is a small thing, but it adds a bunch of nice clarity.
2024-04-06 22:50:26 -07:00
Michael Gottesman
b3e837c16c [region-isolation] Enable region isolation by default with strict-concurrency.
I added a disable flag -disable-region-based-isolation-with-strict-concurrency
so that we do not need to update the current tests. It is only available when
asserts are enabled to ensure users cannot use it.

rdar://125918028
2024-04-04 13:07:32 -07:00
Michael Gottesman
2f9b519758 [region-isolation] Wordsmith "{access,use} here could race".
I am doing this since it isn't always going to be an access. We may not have
memory. We are talking about uses here!

I was able to just use sed so it was an easy fix.
2024-03-23 17:19:09 -07:00
Michael Gottesman
357a53ab48 [region-isolation] Clean up use after transfer error to use the dynamic isolation information of the transfered operand value in its diagnostic message.
As an example of the change:

-  // expected-note @-1 {{'x' is transferred from nonisolated caller to main actor-isolated callee. Later uses in caller could race with potential uses in callee}}
+  // expected-note @-1 {{transferring disconnected 'x' to main actor-isolated callee could cause races in between callee main actor-isolated and local nonisolated uses}}

Part of the reason I am doing this is that I am going to be ensuring that we
handle a bunch more cases and I wanted to fix this diagnostic before I added
more incaranations of it to the tests.
2024-03-22 13:12:51 -07:00
Michael Gottesman
7368de2a20 [region-isolation] Remove variable_defined_here from named use after transfer error.
This is just a pseudo-why are these two things part of the same region error. I
am going to remove this for now and the proper form of this diagnostic will come
back when I land the region history functionality.
2024-03-19 13:19:08 -07:00
Michael Gottesman
99e3f7fb13 [region-isolation] Make RegionBasedIsolation an upcoming feature for swift 6.
To make the tests pass, I had to teach sil-opt how to setup upcoming features
since it did not know how to parse them.

rdar://124100266
2024-03-05 15:15:14 -08:00
Michael Gottesman
f296529ee0 [region-isolation] Change the main race error to be "transferring {could,may} cause a race"
As I was updating tests in the previous commit, I noticed that this would read better to me.
2024-02-22 13:50:06 -08:00
Michael Gottesman
7fe100a762 [region-isolation] Clean up the named value transfer warning. 2024-02-22 13:50:06 -08:00
Michael Gottesman
f87dbb5181 [region-isolation] Eliminate term "binding" from diagnostic. 2024-02-06 16:18:43 -08:00
Michael Gottesman
fef1b5e3df [region-isolation] Use VariableNameUtils to emit name diagnostics when possible.
A name diagnostic looks as follows:

Some notes:

1. VariableNameUtils still doesn't pattern match all cases. In the cases where
we fail to pattern match, I fall back to the old diagnostics. I am going to be
adding tests/etc specific to VariableNameUtils in a later patch.

2. I took this as an opportunity to begin preparing to change the diagnostics
into diags of the following form:

a. The main diagnostic is changed to something short "transferring non-Sendable
%0 could yield races with later accesses".

b. I added a longer note at the same location that explains that our caller is
in a specific isolation domain and our callee is isolated differently.

c. I added a note on the definition location of the identified value.
2024-02-06 13:42:35 -08:00
Doug Gregor
6ebb0ff560 Replace AsyncIteratorProtocol.nextElement() with isolated next(_:)
Use an optional isolated parameter to this new `next(_:)` overload to
keep it on the same actor as the caller, and pass `#isolation` when
desugaring the async for..in loop. This keeps async iteration loops on
the same actor, allowing non-Sendable values to be used with many
async sequences.
2024-01-25 16:04:48 -08:00
Michael Gottesman
3641050675 [region-isolation] Wordsmith some diagnostics.
I tried to make them shorter and standardized on "; later accesses could race"
as the mark on a diagnostic that the problem was that a race was occuring
(before we had several small different variations).
2024-01-19 15:38:41 -08:00
Holly Borla
d37b9763b6 [Concurrency] Promote StrictConcurrency to an upcoming feature flag. 2024-01-11 21:23:25 -08:00
Sophia Poirier
223a9eeb11 [Concurrency] split global variable tests from experimental feature strict concurrency tests 2024-01-06 11:00:30 -08:00
Sophia Poirier
e8945ac193 [Concurrency] @preconcurrency import downgrades globals concurrency errors to warnings 2024-01-05 16:35:02 -08:00
Sophia Poirier
4abb567fb0 [Concurrency] correct some strict concurrency warnings to be errors in Swift 6 2024-01-05 16:23:48 -08:00
Holly Borla
0c6c369e0c [Concurrency] Apply nonisolated(unsafe) to iterator variables for
async for-in loops.

Async iterators are not `Sendable`; they're only meant to be used from
the isolation domain that creates them. But the `next()` method runs on
the generic executor, so calling it from an actor-isolated context passes
non-`Sendable` state across the isolation boundary. `next()` should
inherit the isolation of the caller, but for now, use the opt out.
2024-01-03 13:39:07 -08:00
Holly Borla
76ae065c29 [Concurrency] Suppress Sendable argument diagnostics for values that come
from `nonisolated(unsafe)` declarations.
2024-01-03 12:32:11 -08:00
Sophia Poirier
18c88e42ed [Sema] nonisolated(unsafe) for local variables 2023-11-30 14:12:22 -08:00
Sophia Poirier
e10504f8f7 parse nonisolated(unsafe) as decl contextual keyword in top-level global scope rather than as function invocation (temporary solution) 2023-11-07 16:15:29 -08:00
Sophia Poirier
77e7dc2c19 Merge pull request #69280 from sophiapoirier/globals_strict_concurrency_opt_out_nonisolated_unsafe
nonisolated(unsafe) to opt out of strict concurrency static checking for global variables
2023-10-26 22:34:22 -07:00
Sophia Poirier
4c9a726183 nonisolated(unsafe) to opt out of strict concurrency static checking for global variables 2023-10-26 16:22:28 -07:00
Michael Gottesman
cb46851194 [region-isolation] Rename the experimental feature to RegionBasedIsolation.
This ensures that the pass is called TransferNonSendable but the experimental
feature is RegionBasedIsolation.
2023-10-26 12:01:44 -07:00
Michael Gottesman
0bad8f9b67 [region-isolation] Rename SendNonSendable.cpp -> TransferNonSendable.cpp. 2023-10-26 12:01:44 -07:00
Michael Gottesman
b53af9419c [send-non-sendable] Add REQUIRES: asserts to concurrency tests that use SendNonSendable. 2023-08-31 19:25:23 -07:00
Michael Gottesman
026f1735b5 [send-non-sendable] Update concurrency tests so that we run them in all concurrency modes as appropriate.
This means that:

1. In test cases where minimal is the default (swift 5 without
-warn-concurrency), I added RUN lines for targeted, complete, and complete +
sns.

2. In test cases where complete is the default (swift 6, -warn-concurrency,
specified complete with -strict-concurrency), I added a send non-sendable run
line.

In each of these cases, I added additional expected-* lines as appropriate so
the tests can compile in each mode successfully.
2023-08-30 13:40:17 -07:00
Sophia Poirier
936ab20e5d enforce under strict concurrency that globals and statics be either isolated to a global actor or Sendable plus immutable
rdar://81629027 Global and static variable data-race safety
2023-08-18 15:08:42 -07:00
Gwynne Raskind
5ab86d969c Add StrictConcurrency as an always-enabled experimental feature
Upcoming and experimental features are supported via command-line flags
and also in the SwiftPM manifest. Introduce it as an experimental
feature so that it can be enabled via SwiftPM without having to resort
to unsafe flags.

The `StrictConcurrency` experimental feature can also provide a
strictness level in the same manner as `-strict-concurrency`, e.g.,
`StrictConcurrency=targeted`. If the level is not provided, it'll be
`complete`.

Note that we do not introduce this as an "upcoming" feature, because
upcoming features should be in their final "Swift 6" form before
becoming available. We are still tuning the checking for concurrency.
2023-06-28 12:06:17 -07:00