Commit Graph

103252 Commits

Author SHA1 Message Date
Owen Voorhees
ff41798687 Update OS versions requiring stdlib OS rpaths 2025-09-22 11:52:44 -07:00
John McCall
75f228040c Fix IRGen to pass complete metadata to various concurrency builtins
Fixes rdar://146155888
2025-09-11 20:06:41 -04:00
Gábor Horváth
816290f0cd [6.2.1][cxx-interop] Do not consider function types fragile
Explanationion: Function pointer types wee always considered fragile in C++ mode,
this manifested as a regression when interfacing with glibc.
Issues: rdar://159184118
Original PRs: #84040
Risk: Low, this only removes a spurious error for library evolution.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-09-09 09:55:52 +01:00
Artem Chikin
174636c7c9 Merge pull request #84111 from artemcm/62_1_DepScanWorkersNoShareDiagEngine
[6.2.1 🍒][Dependency Scanning] Give each scanner worker a unique Diagnostic Engine
2025-09-08 12:14:23 -04:00
Konrad `ktoso` Malawski
d76b070efd Merge pull request #84067 from swiftlang/pick-6.2.1-nonisolatednonsending-by-default-and-nondistributed 2025-09-05 16:05:27 +09:00
Konrad Malawski
7713dec67d [Distributed] We're currently not using this isDistributedThunk func 2025-09-05 08:35:17 +09:00
Dario Rexin
8177a6a21a Merge pull request #84008 from drexin/wip-159143492-6.2.1
[6.2.1][IRGen] Fix computation of spare bits for fixed arrays
2025-09-04 13:25:55 -07:00
eeckstein
d7ff11b2c4 Merge pull request #83966 from eeckstein/fix-combine-apply-of-convertfunction-6.2.1
[6.2.1] SILCombine: fix `convert_function` -> `apply` peephole for generic function types
2025-09-04 10:25:54 +02:00
Artem Chikin
dbf15f9c09 [6.2][Dependency Scanning] Give each scanner worker a unique Diagnostic Engine
Otherwise, when multiple workers encounter a diagnostic simultaneously we can encounter races which lead to corrupted diagnostic data or crashes

Resolves rdar://159598539
2025-09-03 12:32:10 -07:00
Dario Rexin
8dc35c846c [IRGen] Fix computation of spare bits for fixed arrays
rdar://159143492

Previously all bits after the spare bits of the first element were marked as spare bits. This caused enum tags to be stored in bits used by the payload.
2025-09-03 10:26:04 -07:00
Konrad Malawski
9524c10a43 [Concurrency/Distributed] ensure distributed thunks are @concurrent
Otherwise the "nonisolated nonsending by default" mode blows up as
distributed thunk signatures dont match expectations.

This undoes the fix from https://github.com/swiftlang/swift/pull/83940
and applies the fix on the synthesis side of the distributed thunks,
such that they are @concurrent always -- which keeps their old semantics
basically, regardless of what "default" mode we have.
2025-09-03 19:00:03 +09:00
Konrad Malawski
4c283e5959 [Concurrency/Distributed] nonisolated-nonsending by default breaks distributed thunks
the new NonisolatedNonsendingByDefault upcoming feature breaks remote
calls in distributed actors, because the expected isolation doesn't
match and the runtime swift_distributed_execute_target_resume will
crash.

This is a short term fix to unblock adopters, however preferably we
should mark the thunks as nonisolated(nonsending), though that seems to
be more involved.

resolves rdar://159247975
2025-09-03 08:21:05 +09:00
nate-chandler
3c1c195500 Merge pull request #83995 from nate-chandler/cherrypick/release/6.2.1/rdar158149082
6.2.1: [AllocBoxToStack] Don't destroy in dead-ends.
2025-08-29 16:35:54 -07:00
Nate Chandler
5851dcb971 [MemoryLifetimeVerifier] Permit leaks in dead-ends 2025-08-28 19:08:41 -07:00
Nate Chandler
eb9f5b2a92 [AllocBoxToStack] Don't destroy in dead-ends.
It is valid to leak a value on paths into dead-end regions.
Specifically, it is valid to leak an `alloc_box`.  Thus, "final
releases" in dead-end regions may not destroy the box and consequently
may not release its contents.  Therefore it's invalid to lower such final
releases to `dealloc_stack`s, let alone `destroy_addr`s.  The in-general
invalidity of that transformation results in miscompiling whenever a box
is leaked and its projected address is used after such final releases.

Fix this by not treating final releases as boundary markers of the
`alloc_box` and not lowering them to `destroy_addr`s and
`dealloc_stack`s.

rdar://158149082
2025-08-28 19:08:41 -07:00
Erik Eckstein
36d2549bf4 SILCombine: fix convert_function -> apply peephole for generic function types
Currently we cannot deal with generic arguments/returns. Bail in this case.

Fixes a compiler crash
rdar://158809851
2025-08-28 07:29:53 +02:00
Pavel Yaskevich
bbb11ec272 [TypeCheckEffects] AbstractFunction: Parameter types should be mapped into context
Parameter type could be represented by an associated type which is
bound to a concrete type by an extension, `AbstractFunction::getType()`
should map it into context before returning because the construct is
that it always produces a function type.

Resolves: rdar://156955193
(cherry picked from commit 32b97d0e2a)
(cherry picked from commit 7f652915d9)
2025-08-27 10:35:50 -07:00
Gábor Horváth
ef63ec99e9 [6.2][cxx-interop] Fix crash when using bridging headers in reverse interop
Explanation: The original code had the assumption we only import
modules. However, there is a flag to import an umbrella header in which
case the clang nodes have no owning module. This PR prevents a null
dereference in that case.
Issues: rdar://157489426
Original PRs: #83540
Risk: Low, added a check to avoid null dereference.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-08-07 15:58:31 +01:00
Augusto Noronha
0f0552886e Merge pull request #83557 from augusto2112/6.2-fix-opaque-infinite-rec
[DebugInfo] Fix infinite recursion when opaque return type is defined inside function returning it
2025-08-06 12:00:30 -07:00
Augusto Noronha
7b46d41823 [DebugInfo] Fix infinite recursion when opaque return type is defined
inside function returning it

A stack overflow would happen when the compiler tried emitting debug
info for a function whose opaque return type was declared inside the
function itself. This fixes the issue by emitting a forward declaration
for the function before emitting it.

rdar://150313956

(cherry picked from commit c03831f70d)
2025-08-05 17:36:28 -07:00
Hamish Knight
a8cea97b4b Merge pull request #82988 from hamishknight/enable-inlinearray-sugar-6.2
[6.2] Enable InlineArray type sugar
2025-08-05 22:21:05 +01:00
Adrian Prantl
95ad22e799 [ClangImporter] Prefer serialized bridging headers in LLDB.
Especially in an explicit modules project, LLDB might not know all the
search paths needed to imported the on disk header.

rdar://157063577
(cherry picked from commit a6678476d8)
2025-08-04 11:15:55 -07:00
Michael Gottesman
99a2db3392 Merge pull request #83410 from gottesmm/release/6.2-156919493
[6.2][concurrency] Emit nonisolated(nonsending) async throw initializers correctly
2025-07-31 09:41:12 -07:00
Pavel Yaskevich
c04eb7c482 [Concurrency] Downgrade errors when isolated member is referenced from a preconcurrency context
Such references used to be downgraded until Swift 6 but since the
context is `@preconcurrency` it should be possible for API authors
to introduce concurrency annotations such as `@Sendable` without
breaking clients even when they are compiled in Swift 6 mode.

Resolves: rdar://157061896
(cherry picked from commit 5ee673f358c9dd7dbbfe58f02bc78af60e0377b8)
2025-07-30 11:03:30 -07:00
Michael Gottesman
dcb3e5c48e [concurrency] Emit nonisolated(nonsending) async throw initializers correctly.
Specifically, we were not inserting the implicit isolated parameter and were not
setting up the actor prologue. To keep this specific to nonisolated(nonsending)
code, I only setup the actor prologue if we know that we have something that is
nonisolated(nonsending).

I also ported some async initializer tests to run with/without
nonisolated(nonsending) just to increase code coverage.

rdar://156919493
(cherry picked from commit 3871d22257)
2025-07-29 20:10:44 -07:00
John McCall
787cca9e37 Rewrite the type of nonisolated(nonsending) closures.
The constraint solver does not reliably give closures a function type
that includes `nonisolated(noncaller)`, even when the immediate context
requires a conversion to such a type. We were trying to work around this
in SILGen, but the peephole only kicked in if the types matched exactly,
so a contextual conversion that e.g. added `throws` was still emitting
the closure as `@concurrent`, which is of course the wrong semantics.
It's relatively easy to avoid all this by just rewriting the closure's
type to include `nonisolated(nonsending)` at a point where we can reliably
decide that, and then SILGen doesn't have to peephole anything for
correctness.

Fixes rdar://155313349
2025-07-28 22:22:54 -04:00
Doug Gregor
20a10c618e [SE-0466] Treat explicit "nonisolated" like implicit "nonisolated" on protocols
Make explicit "nonisolated" also not special on protocols, so a
nonisolated protocol does not suppress default isolation.
SendableMetatype is the proper way to suppress default isolation for a
protocol.

Unfortunately, these rules made it appear like issue #82168
was fixed, when in fact it was not. Keep the test case, but as a
failing test, and we'll investigate separately.
2025-07-25 12:21:38 -07:00
Doug Gregor
5abbf2e4c9 [SE-0466] Under main actor default isolation, explicit nonisolated is not special
Given an explicitly-nonisolated type such as

    nonisolated struct S { }

all extensions of S were also being treated as nonisolated. This meant
that being implicitly nonisolated (i.e., when you're using nonisolated
default isolation) was different from explicitly-writing nonisolated,
which is unfortunate and confusing. Align the rules, such that an
extension of S will get default isolation:

    extension S {
      func f() { } // @MainActor if we're in main actor default isolation
    }
2025-07-25 12:21:35 -07:00
Doug Gregor
4ffe06ed7c [SE-0466] Extensions and members thereof can apply default isolation
Extensions of nonisolated types can get default isolation from context
(e.g., @MainActor) independently. This was previously true for members,
but not conformances, and recently regressed for members. Fix the logic
to consistently allow such extensions to be default main-actor
isolated, which affects both their members and conformances.

Fixes rdar://156644976.
2025-07-25 12:21:08 -07:00
Shubham Sandeep Rastogi
87925d5c37 Revert "Set the Compilation directory when generating the Skeleton CU"
This reverts commit b286b1c3a5.

Reverted because fix for rdar://131726681 broke rdar://154247270

Reverting and will try to fix properly later.

We will not land this in 6.2

(cherry picked from commit 5b4fdd6e62)
2025-07-24 11:02:31 -07:00
Doug Gregor
2db51c9159 Merge pull request #82923 from DougGregor/sendable-prohibits-mainactor-by-default-6.2
[6.2] [SE-0466] Enable SendableProhibitsMainActorInference by default
2025-07-23 20:04:56 -07:00
Holly Borla
276e5de462 [Concurrency] Local storage is always default nonisolated.
(cherry picked from commit 7b0ba7b5ed)
2025-07-22 21:36:59 -07:00
Holly Borla
2697773f21 [Concurrency] Only apply default main actor to local and nested
decls that are in a main actor isolated context.

This prevents `@MainActor` from being inferred in a context where
it cannot be used, while still allowing main actor code to be used
in local contexts that are also main actor isolated.

(cherry picked from commit 858e145069)
2025-07-22 21:15:26 -07:00
Gábor Horváth
7429124124 Merge pull request #83065 from Xazax-hun/guard-more-objc-on-6.2
[6.2][cxx-interop] Types exposed from ObjC modules should be behind a macro
2025-07-22 11:20:22 +01:00
Dario Rexin
b7acd126ff Merge pull request #83074 from drexin/wip-155641749
[6.2][IRGen] Set generic context before getting call emission in visitFull…
2025-07-21 15:56:30 -07:00
Pavel Yaskevich
61157cdd36 Merge pull request #83165 from xedin/nonisolated-nonseding-with-special-decls-6.2
[6.2][Concurrency] NonisolatedNonsendingByDefault: Infer `nonisolated(nonsending)` on declaration with special special semantics
2025-07-18 09:40:08 -07:00
Joe Groff
6516d94624 Merge pull request #83142 from jckarter/semantic-store-preconcurrency-6.2
[6.2] SILGen: Have emitSemanticStore cast off concurrency annotations.
2025-07-18 08:48:30 -07:00
Gabor Horvath
f48da45438 [cxx-interop] Configure requires ObjC from frontend option
We sometimes don't have the information in the modulemaps whether a
module requires ObjC or not. This info is useful for reverse interop.
This PR introduces a frontend flag to have a comma separated list of
modules that we should import as if they had "requires ObjC" in their
modulemaps.
2025-07-18 10:35:51 +01:00
Michael Gottesman
64a53b483e Merge pull request #83084 from gottesmm/release/6.2-rdar155905383
[6.2][concurrency] Make optimize hop to executor more conservative for 6.2 around caller isolation inheriting functions.
2025-07-17 22:04:17 -07:00
Pavel Yaskevich
fb0daaa78a [Concurrency] NonisolatedNonsendingByDefault: Extend nonisolated(nonsending) to _openExistential
`_openExistential` is type-checked in a special way which
means that we need to explicitly inject `nonisolated(nonsending)`
isolation when forming a reference to this builtin.

(cherry picked from commit 358869ff54)
2025-07-17 18:08:30 -07:00
Pavel Yaskevich
18817b823f [Concurrency] NonisolatedNonsendingByDefault: Extend nonisolated(nonsending) to withoutActuallyEscaping
`withoutActuallyEscaping` is type-checked in a special way which
means that we need to explicitly inject `nonisolated(nonsending)`
isolation when forming a reference to this builtin.

(cherry picked from commit 48f4d7b688)
2025-07-17 18:08:30 -07:00
Joe Groff
07a3dfb1d1 SILGen: Have emitSemanticStore cast off concurrency annotations.
If a function is being semantically treated as having different concurrency
annotations because of a `@preconcurrency` import or language mode setting,
then SILGen may try to store an argument or result for a call using a value
that differs only in concurrency annotations, which can be safely bitcast
away.

Fixes rdar://154520999
2025-07-17 11:16:55 -07:00
Michael Gottesman
82b0ec3de0 [silgen] Make sure that thunks that convert to/from nonisolated(nonsending) handle hopping correctly.
Specifically:

1. When we convert a function to nonisolated(nonsending), we need to
make sure that in the thunk we hop upon return since nonisolated(nonsending)
functions are assumed to preserve the caller's isolation.

2. When we convert a function from nonisolated(nonsending), we need to
make sure that in the thunk we hop onto the actor that we are passing in as the
isolated parameter of the nonisolated(nonsending) function. This ensures that
the nonisolated(nonsending) function can assume that it is already on its
isolated parameter's actor at function entry.

rdar://155905383
2025-07-17 10:55:59 -07:00
Holly Borla
94df8da676 [Concurrency] Downgrade isolated conformances to SendableMetatype
protocols to a warning for implicitly `@preconcurrency` protocols.

(cherry picked from commit 4b50238ebf)
2025-07-17 10:28:27 -07:00
Anthony Latsis
ffa408d9b8 Merge pull request #83110 from swiftlang/jepa-release
[6.2] Sema: Make `@concurrent` not imply `async` on closures
2025-07-17 16:44:44 +01:00
Doug Gregor
5797130e90 Merge pull request #83119 from DougGregor/unsafe-covers-unsafe-6.2 2025-07-17 02:02:18 -07:00
Michael Gottesman
7f9eb4ccb1 Merge pull request #83102 from gottesmm/release/6.2-revert
[6.2] Revert nonisolated(unsafe) closure inference
2025-07-16 22:03:39 -07: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