Commit Graph

184211 Commits

Author SHA1 Message Date
Guillaume Lessard
66e62302fa [test] OutputRawSpan tests 2025-07-16 17:19:41 -07:00
Yuta Saito
500e25ced1 [Concurrency] Unskip isolated-conformance runtime test on WebAssembly 2025-07-16 23:50:35 +00:00
Yuta Saito
e6453a34a0 [Concurrency] Fix runtime isolated-conformance checks with static stdlib
Most of linkers pull object files from static archives only if any
symbol from that object file is referenced, even if the object contains
a ctor code. `Setup.cpp` didn't have any symbols referenced from
other code, so it was not linked in when the concurrency runtime was
linked in statically. This commit moves the ctor code to `Task.cpp`
to ensure that it is always linked in.
2025-07-16 23:50:31 +00:00
Doug Gregor
b6ea29613e [Strict memory safety] "unsafe" expression never propagates unsafe outward
In the effects checker, we were propagating the "has an unsafe use
site" outside of an `unsafe` expression. The result of this is that we
would not produce a warning for silly expressions like `unsafe unsafe
ptr.pointee`, where the first (outer) `unsafe` is unnecessary. Stop
propagating that bit so we properly diagnose the spurious "unsafe".

Fixes issue #82315 / rdar://153672668.
2025-07-16 15:43:59 -07:00
Anthony Latsis
dc1458762e Sema: Make @concurrent not imply async on closures
The present approach is not prudent because `@concurrent` synchronous
functions, a natural extension, are a likely-to-happen future direction,
whereas the current inference rule is entirely grounded on `@concurrent`
being exclusive to async functions.

If we were to ship this rule, we would have to keep the promise for
backwards compatibility when implementing the aforementioned future
direction, replacing one inconsistency with another, and possibly
introducing new bug-prone expression checking code.

```swift
func foo(_: () -> Void) {}
func foo(_: () async -> Void) {}

// In a future without this change and  `@concurrent` synchronous
// functions accepted, the first call resolves to the first overload,
// and the second call resolves to the second, despite `@concurrent` no
// longer implying `async`.
foo { }
foo { @concurrent in }
```

This change also drops the fix-it for removing `@concurrent` when used
on a synchronous closure. With the inference rule gone, and the
diagnosis delayed until after solution application, this error raises a
fairly balanced choice between removing the attribute and being
explicit about the effect, where a unilateral suggestion is quite
possibly more harmful than useful.

(cherry picked from commit 58d5059617)
2025-07-16 20:49:37 +01:00
Michael Gottesman
48b88b0847 [micro-opt] Flip a check to improve perf. 2025-07-16 12:18:40 -07:00
Artem Chikin
d58873b21c [Test Only] Add a test for correctly querying Clang global variable linkage when using '-clang-target' 2025-07-16 10:58:18 -07:00
Doug Gregor
6e419b6345 Revert "[6.2] Accept @cdecl global functions and enums, behind experimental feature flags" 2025-07-16 10:05:35 -07:00
Michael Gottesman
348720b830 Revert "[rbi] Treat a partial_apply as nonisolated(unsafe) if all of its captures are nonisolated(unsafe)."
This reverts commit 6ce93c8a37.
2025-07-16 09:58:09 -07:00
Michael Gottesman
e81838f672 Revert "[region-isolation] Add a test showing that we do not infer nonisolated(unsafe) onto named closures."
This reverts commit 4ccb39e943.
2025-07-16 09:58:08 -07:00
Michael Gottesman
2e06769dbc Revert "Fix an error message due to a difference in Task.detached from 6.2 and main."
This reverts commit b81f6bbcda.
2025-07-16 09:58:06 -07:00
Doug Gregor
73530bf957 Merge pull request #83088 from DougGregor/se-0466-nested-no-inference-6.2
[6.2] [SE-0466] Nested types of nonisolated types don't infer main-actor isolation
2025-07-16 09:44:00 -07:00
Alexis Laferrière
ed65bb9a46 Merge pull request #82791 from xymus/cdecl-6.2
[6.2] Accept `@cdecl` global functions and enums, behind experimental feature flags
2025-07-16 09:27:04 -07:00
nate-chandler
b84b357a35 Merge pull request #83095 from ktoso/pick-patch-20
[6.2] CI: Temporarily disable taskExecutor test with Task.immediate
2025-07-16 06:34:06 -07:00
Konrad `ktoso` Malawski
3fbb1958ef CI: Temporarily disable taskExecutor test with Task.immediate
rdar://155596073 Task executors execution may not always hop as expected

I'm investigating a fix here as we speak, but disabling the specific piece of the test while we work on it.
2025-07-16 21:16:33 +09:00
Gábor Horváth
ab123929f6 [6.2][cxx-interop] Types exposed from ObjC modules should be behind a macro
Explanation: We the generated reverse interop headers to be valid C++,
so every declaration coming from an Obj-C module should be behind an
ifdef. Unfortunately, we do not always have this information but we do
know that our frameworks contain Obj-C code. So this PR makes sure every
entity coming from our frameworks are behind ifdef.
Issues: rdar://152836730
Original PRs: #83002
Risk: Low, the change is narrow and straightforward.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-07-16 11:19:55 +01:00
Doug Gregor
a4a39f2a98 [SE-0466] Nested types of nonisolated types don't infer main-actor isolation
Under discussion as part of an amendment to SE-0466, limit default main
actor inference so it doesn't apply to a nested type within a
nonisolated type.
2025-07-15 20:15:35 -07:00
Pavel Yaskevich
d7808f7804 Merge pull request #83064 from xedin/rdar-155847011-6.2
[6.2][Concurrency] Replace `nonisolated` with `nonisolated(nonsending)` when isolation is inferred
2025-07-15 17:41:06 -07:00
Michael Gottesman
182149978e [concurrency] Make optimize hop to executor more conservative for 6.2 around caller isolation inheriting functions.
Specifically for 6.2, we are making optimize hop to executor more conservative
around caller isolation inheriting functions. This means that we are:

1. No longer treating calls to caller isolation inheriting functions as having a
hop in their prologue. In terms of this pass, it means that when determining
dead hop to executors, we no longer think that a caller isolation inheriting
function means that an earlier hop to executor is not required.

2. Treating returns from caller isolation inheriting callees as requiring a
hop. The reason why we are doing this is that we can no longer assume that our
caller will hop after we return.

Post 6.2, there are three main changes we are going to make:

* Forward Dataflow

Caller isolation inheriting functions will no longer be treated as suspension
points meaning that we will be able to propagate hops over them and can assume
that we know the actor that we are on when we enter the function. Practically
this means that trees of calls that involve just nonisolated(nonsending) async
functions will avoid /all/ hop to executor calls since we will be able to
eliminate all of them since the dataflow will just propagate forward from the
entrance that we are already on the actor.

* Backwards Dataflow

A caller isolation inheriting call site will still cause preceding
hop_to_executor functions to be live. This is because we need to ensure that we
are on the caller isolation inheriting actor before we hit the call site. If we
are already on that actor, the hop will be eliminated by the forward pass. But
if the hop has not been eliminated, then the hop must be needed to return us to
the appropriate actor.

We will also keep the behavior that returns from a caller isolation inheriting
function are considered to keep hop to executors alive. If we were able to
propagate to a hop to executor before the return inst with the forward dataflow,
then we know that we are guaranteed to still be on the relevant actor. If the
hop to executor is still there, then we need it to ensure that our caller can
treat the caller isolation inheriting function as a non-suspension point.

rdar://155905383
(cherry picked from commit b3942424c8)
2025-07-15 17:32:19 -07:00
Michael Gottesman
e73396bc8a [sil] Add the ability to mark a function with isolation just so we can write more concurrency tests in SIL.
Specifically, we write a string out like:

sil [isolation "$REPRESENTATION OF ISOLATION"] @function : $@convention(thin) ...

The idea is that by using a string, we avoid parsing issues of the isolation and
have flexibility. I left in the way we put isolation into the comment above
functions so I did not break any tests that rely on it. I also made it so that
we only accept this with sil tests that pass in the flag
"sil-print-function-isolation-info". I am going to for the next release put in a
full real implementation of this that allows for actor isolation to become a
true first class citizen in SIL. But for now this at least lets us write tests
in the short term.

Since this is temporary and behind a flag, I did not add support for
serialization since this is just for writing textual SIL tests.

(cherry picked from commit ee3027c2ca)

Conflicts:
	lib/SIL/Parser/ParseSIL.cpp
2025-07-15 17:12:01 -07:00
Xi Ge
6f4d55a901 Merge branch 'release/6.2' into cdecl-6.2 2025-07-15 14:50:10 -07:00
Guillaume Lessard
5ba72f267f Merge pull request #83023 from glessard/rdar155474776-extracting-62
[SE-0488, 6.2] Implementation for SE-0488
2025-07-15 13:59:29 -07:00
Dario Rexin
4a8ada3fb0 [IRGen] Set generic context before getting call emission in visitFullApplySite
rdar://149007227

Without the generic context, the result type can't be mapped into the current context, causing the compiler to crash.
2025-07-15 13:36:16 -07:00
Saleem Abdulrasool
8bf3af09a6 Merge pull request #82166 from Steelskin/fabrice/6.2-line-directive
🍒 [6.2] line-directive: Stop expanding response files
2025-07-15 11:40:13 -07:00
Pavel Yaskevich
a7e44d422f Merge pull request #83048 from xedin/rdar-153487603-6.2
[6.2][Serialization] Move `nonisolated(nonsending)` isolation kind above g…
2025-07-15 11:20:22 -07:00
Meghana Gupta
5d1f25e419 Merge pull request #83058 from meg-gupta/fixsemanticarccp
[6.2] Bailout from an illegal transformation in semantic arc opts
2025-07-15 11:18:06 -07:00
Pavel Yaskevich
84f70f3792 [Concurrency] Replace nonisolated with nonisolated(nonsending) when isolation is inferred
With `NonisolatedNonsendingByDefault` an explicit `nonisolated`
attribute in declaration context is inferred to mean `nonisolated(nonsending)`
and it should be printed as such in interface files and other places.

The inference logic that did didn't remove the original attribute
which meant that it would be printed twice i.e.
`nonisolated nonisolated(nonsending) func test() async` which is
incorrect and would fail swift interface validation.

Resolves: rdar://155847011
(cherry picked from commit b519c07428)
2025-07-15 09:20:33 -07:00
Meghana Gupta
8f00bc4fe8 Bailout from an illegal transformation in semantic arc opts
tryJoinIfDestroyConsumingUseInSameBlock replaces a copy with its operand
when there is no use of the copy's operand between the copy's forwarded consuming use
and the copy operand's destroy in the same block. It is illegal to do this transformation
when there is a non-consuming use of the copy operand after the forwarded consuming use of the copy.

The code checking this illegal case was not considerin the case where the consuming use of the copy
was in the same instruction as the non-consuming use of the copy operand.

rdar://154712867
2025-07-15 03:41:05 -07:00
Hamish Knight
234a41567f Merge pull request #83036 from hamishknight/origami-6.2
[6.2] [Sema] Avoid folding sequences multiple times for completion
2025-07-15 09:15:17 +01:00
Rintaro Ishizaki
e5c2346e47 Merge pull request #83041 from rintaro/6.2-rdar155463166
[6.2][Test] Fix test failure caused by invalid iOS version for availability
2025-07-14 19:20:10 -07:00
Joe Groff
e9d2e8ac48 Merge pull request #83038 from jckarter/case-binding-addressable-scopes-6.2
[6.2] SILGen: Properly set up addressability scopes for case pattern bindings.
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-07-15-a
2025-07-14 17:58:25 -07:00
Doug Gregor
e5658e0087 Merge pull request #83020 from DougGregor/prohibit-isolated-conformance-capture-check-6.2 2025-07-14 15:37:31 -07:00
Meghana Gupta
cfe2a7030f Merge pull request #82963 from meg-gupta/disablefso2
[6.2] Disable function signature optimization on functions with lifetime dependencies
2025-07-14 15:36:46 -07:00
Pavel Yaskevich
64c8c3d5f6 [Serialization] Move nonisolated(nonsending) isolation kind above global actor one
Global actor kind also appends type offset that indicates what
global actor to use with the type. All of the isolation kinds
should be placed above it to make sure that there is never a
clash when i.e. `MainActor` is serialized as id `1`.

Resolves: rdar://153487603
(cherry picked from commit ace6f738ba)
2025-07-14 14:33:28 -07:00
Jonas Devlieghere
3d0ceb7715 Merge pull request #82997 from augusto2112/change-remote-addr-6.2-3
[NFC][RemoteInspection] Add an opaque AddressSpace field to RemoteAddress
2025-07-14 13:24:19 -07:00
Michael Gottesman
187b1eedf7 Merge pull request #82776 from gottesmm/release/6.2-154139237
[6.2] [nonisolated-nonsending] Make the AST not consider nonisolated(nonsending) to be an actor isolation crossing point.
2025-07-14 13:19:55 -07:00
Meghana Gupta
6e2065106e Merge pull request #82974 from meg-gupta/disablerrnccp
[6.2] Disable retain and release sinking when rc root values are ~Copyable
2025-07-14 12:48:27 -07:00
Rintaro Ishizaki
4101b5e1e9 [Test] Fix test failure caused by invalid iOS version for availability
'20.0' is not a valid version number for iOS

rdar://155463166
(cherry picked from commit dfacf99526)
2025-07-14 11:06:25 -07:00
Hamish Knight
e653a22431 [Sema] Make change less risky for 6.2
Revert assertion changes and flip the condition to only apply when
doing completion.
2025-07-14 17:49:30 +01:00
Hamish Knight
5d93006d4c [Sema] Avoid folding sequences multiple times for completion
Completion can end up calling into pre-checking multiple times in
certain cases, make sure we don't attempt to fold a SequenceExpr
multiple times since its original AST is in a broken state
post-folding. Instead, just return the already-folded expression.

rdar://133717866
2025-07-14 17:49:23 +01:00
Joe Groff
5e021bc55a SILGen: Properly set up addressability scopes for case pattern bindings.
In order to accommodate case bodies with multiple case labels, the AST
represents the bindings in each pattern as a distinct declaration from
the matching binding in the case body, and SILGen shares the variable
representation between the two declarations. That means that the two
declarations also need to be able to share an addressable representation.
Add an "alias" state to the addressable buffer data structures so that
we can refer back to the original case label var decl when the case body
var decl is brought into scope, so that accesses through either decl
properly force the addressable representation.

Fixes rdar://154543619.
2025-07-14 09:10:35 -07:00
Doug Gregor
47bb174683 Merge pull request #83013 from DougGregor/no-mangled-name-span-metadata-6.2 2025-07-14 08:37:14 -07:00
Alastair Houghton
eefdd69c8d Merge pull request #82915 from al45tair/eng/PR-151147606-take2
[Concurrency] Remove custom global executors from 6.2.
2025-07-14 16:20:57 +01:00
Pavel Yaskevich
c4a3d31ad0 Merge pull request #82998 from xedin/rdar-155589753-6.2
[6.2][Concurrency] Don't downgrade explicit isolation attribute clashes
2025-07-13 08:22:58 -07:00
Guillaume Lessard
6414aa226f [stdlib] rename RawSpan.extracting functions 2025-07-12 22:58:00 -07:00
Guillaume Lessard
ac3e47612c [stdlib] rename Span.extracting functions 2025-07-12 22:58:00 -07:00
Doug Gregor
74b54fea5c Use the "prohibits isolated conformances" check for capture metatypes
When checking whether a capture of a metatype is Sendable, we had an
incomplete and incorrect check for SendableMetatype conformance.
Replace that with the proper "prohibits isolated conformances" check
on the generic signature, which matches what we do on the caller side.

Fixes issue #82905 / rdar://155399531.
2025-07-12 08:47:14 -07:00
Evan Wilde
d438c883f9 Merge pull request #82970 from etcwilde/ewilde/6.2-skip-unused-sections
[6.2🍒]: RemoteInspection: Skip unused ELF section headers
2025-07-11 23:23:22 -07:00
Guillaume Lessard
746324b4ba [test] fix test of InlineArray initializer 2025-07-11 19:03:03 -07:00
Guillaume Lessard
402a0cf2c8 [stdlib] remove bulk-update from MutableRawSpan per SE-0485 2025-07-11 19:03:03 -07:00