Commit Graph

184225 Commits

Author SHA1 Message Date
Konrad Malawski
838bc9ee67 [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 18:58:49 +09:00
Konrad Malawski
011d2d2edc [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-08-29 16:38:10 +09:00
nate-chandler
5f20a5b8b5 Merge pull request #83962 from nate-chandler/cherrypick/release/6.2/rdar158149082
6.2: [AllocBoxToStack] Don't destroy in dead-ends.
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-29-a
2025-08-28 14:26:38 -07:00
Nate Chandler
5798e71baf [MemoryLifetimeVerifier] Permit leaks in dead-ends 2025-08-28 05:47:40 -07:00
eeckstein
6713168abd Merge pull request #83947 from eeckstein/fix-combine-apply-of-convertfunction-6.2
[6.2] SILCombine: fix `convert_function` -> `apply` peephole for generic function types
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-28-a
2025-08-28 06:38:46 +02:00
eeckstein
90e599b174 Merge pull request #83946 from eeckstein/fix-simplify-alloc-stack-apply-6.2
[6.2] Optimizer: fix handling of dependent existential archetypes in `alloc_stack` and `apply` simplification
2025-08-28 06:38:32 +02:00
Allan Shortlidge
59fa85811b Merge pull request #83955 from tshortli/nsmanaged-attr-test-xcode26-6.2
[6.2] Tests: Update the nsmanaged-attr.swift test for the Xcode 26 SDKs
2025-08-27 18:57:39 -07:00
Nate Chandler
8e98bcfefd [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-27 17:12:51 -07:00
nate-chandler
c89bc61167 Merge pull request #83711 from nate-chandler/cherrypick/release/6.2/rdar158083136
6.2: [InlineArray] Fix outlining metadata collection.
2025-08-27 12:57:54 -07:00
Allan Shortlidge
5fced9417d Tests: Update the nsmanaged-attr.swift test for the Xcode 26 SDKs.
Something has changed about the CoreData module and caused the declarations in
this test interface to now be printed with `nonisolated` modifiers.

Resolves rdar://159293226.
2025-08-27 11:10:09 -07:00
Erik Eckstein
bf3a05b7a5 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-27 17:39:12 +02:00
Erik Eckstein
77a2954751 Optimizer: fix handling of dependent existential archetypes in alloc_stack and apply simplification
When replacing an opened existential type with the concrete type, we didn't consider that the existential archetype can also be a "dependent" type of the root archetype.
For now, just bail in this case. In future we can support dependent archetypes as well.

Fixes a compiler crash.
rdar://158594365
2025-08-27 17:14:51 +02:00
Erik Eckstein
9dfe54075a AST: add Type.interfaceTypeOfArchetype and some related APIs 2025-08-27 16:52:28 +02:00
Erik Eckstein
0f485b6efc Swift AST: add some Type APIs 2025-08-27 16:52:19 +02:00
Pavel Yaskevich
2623c4bdd7 Merge pull request #83863 from xedin/rdar-158629300-6.2
[6.2][CSSimplify] SE-0324: Use correct conversion when converting array types
2025-08-22 17:26:28 -07:00
Guillaume Lessard
d03de08221 Merge pull request #83775 from glessard/rdar158440246-62
[stdlib, 6.2.x] guard against deinitializing empty OutputSpan instances
2025-08-22 13:42:00 -07:00
Guillaume Lessard
39cc73b97d Merge pull request #83438 from glessard/rdar157064330-also-available-now
[stdlib, 6.2] fix availability of `Span.bytes`
2025-08-22 09:57:50 -07:00
finagolfin
cd62ce002c Merge pull request #83503 from finagolfin/droid
[6.2][build] Make it possible to build a cross-compilation toolchain for Android, including Testing

Add a linker flag for the upcoming 16 KB page support in Android, generate an Android CMake toolchain file that can be used to cross-compile repos like cmark and Testing, and add a build flag that makes it easy to build cross-compilation toolchains, by disabling the cross-compilation of all host tools and macros for listed --cross-compile-hosts, leaving only the Swift runtime libraries in a cross-compilation SDK.
2025-08-22 16:42:24 +05:30
Max Desiatov
94539464ca [6.2] Embedded Wasm: enable import WASILibc (#83846)
**Explanation**: Cherry-pick of #83792, merged as 450cb14597
WASILibc wasn't built for the embedded stdlib in `stdlib/public/Platform/CMakeLists.txt`. New `copy_wasilibc_modulemap_embedded_resource` and `embedded-stdlib-platform-${triple}` targets are added, the latter for `wasm32-unknown-wasip1` only for now. Also added a `wasilibc_functions.swift` test to verify the result.
**Scope**: limited to Embedded Swift for Wasm;
**Risk**: low due to limited scope;
**Testing**: added new lit test to the existing Embedded Swift test suite;
**Issue**: rdar://157467412
**Reviewer**: @bnbarham
2025-08-22 09:28:23 +01:00
Pavel Yaskevich
26ba69ab79 [CSSimplify] SE-0324: Use correct conversion when converting array types
If the argument type is an array and it's passed to an imported declaration
that accepts a raw pointer, the solver should use an "array-to-c-pointer"
conversion instead of the one for pointers.

Resolves: rdar://158629300
(cherry picked from commit 29b04f4a63)
2025-08-21 16:00:48 -07:00
Egor Zhdan
4c68a0632d Merge pull request #83844 from swiftlang/egorzhdan/6.2-frt-windows
🍒[cxx-interop] Enable reference-counted types on Windows
2025-08-21 23:25:44 +01:00
Egor Zhdan
5c7d5f6414 [cxx-interop] Enable reference-counted types on Windows
This enables the use of reference-counted foreign reference types on Windows. As it turns out, the assertion that was failing on Windows previously was unnecessary. This also enabled many of the tests on Windows.

rdar://154694125 / resolves https://github.com/swiftlang/swift/issues/82643

(cherry picked from commit b440c4ff70)
2025-08-21 11:20:14 +01:00
Egor Zhdan
eaf9a80ab8 Merge pull request #83810 from egorzhdan/egorzhdan/6.2-c-frt-validation
🍒[cxx-interop] Validate C foreign reference types
2025-08-21 09:55:26 +01:00
Pavel Yaskevich
f408b2db4a Merge pull request #82922 from xedin/nonexhaustive-enums-6.2
[6.2][AST/Sema] SE-0487: Implement `@nonexhaustive` attribute and new enum exhaustivity checking rule
2025-08-20 20:31:07 -07:00
Pavel Yaskevich
bdb25f4fec [AST] SE-0487: Promote NonexhaustiveAttribute to a language feature
The proposal [has been accepted](https://forums.swift.org/t/accepted-se-0487-nonexhaustive-enums/81508)
which makes the feature experimental no longer.

(cherry picked from commit a7ecd309d4)
2025-08-20 09:24:46 -07:00
Egor Zhdan
a57432aae9 Merge pull request #83815 from egorzhdan/egorzhdan/6.2-retain-release-unsigned
🍒[cxx-interop] Allow retain/release operations to return an unsigned integer
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-20-a swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-21-a
2025-08-20 02:58:41 +01:00
Egor Zhdan
f9ede2a4ff Merge pull request #83804 from egorzhdan/egorzhdan/6.2-weak-references
🍒[cxx-interop] Prohibit weak references to foreign reference types
2025-08-19 20:19:44 +01:00
Egor Zhdan
44429648ea [cxx-interop] Allow retain/release operations to return an unsigned integer
Release/retain functions for C++ foreign reference types might return a reference count as an integer value.

Swift previously emitted an error for such functions, saying that the retain/release functions need to return void or a reference to the value.

rdar://157853183

(cherry picked from commit 3887ed0637)
2025-08-19 18:11:18 +01:00
Egor Zhdan
fd7b7fede2 [cxx-interop] Validate C foreign reference types
Swift validates the retain/release operations for foreign reference types to check for obvious errors, e.g. a wrong parameter type or return type.

That logic was only running for C++ foreign reference types. This patch enables it for C foreign reference types as well.

rdar://158609723
(cherry picked from commit c73f528b82)
2025-08-19 15:09:39 +01:00
Egor Zhdan
92b7bc7c5e [cxx-interop] Prohibit weak references to foreign reference types
This fixes a runtime crash when a `weak` reference to a C++ foreign reference type is used.

Instead of a runtime crash, Swift would now emit a compiler error saying that `weak` keyword is incompatible with foreign reference types.

rdar://124040825 / resolves https://github.com/swiftlang/swift/issues/83080
(cherry picked from commit 9abadf5483)
2025-08-19 12:19:43 +01:00
Pavel Yaskevich
1d65a560d7 [AST/Sema] SE-0487: Remove @preEnumExtensibility attribute
(cherry picked from commit 0444d297b6)
2025-08-18 23:58:29 -07:00
Pavel Yaskevich
0286f4ab82 [AST/Sema] SE-0487: Expand @nonexhaustive attribute to support warn argument
The spelling `@nonexhaustive(warn)` replaces `@preEnumExtensibility`
attriubte.

(cherry picked from commit 43eec8fede)
2025-08-18 23:58:29 -07:00
Pavel Yaskevich
c9722333b9 [AST/Sema] SE-0487: Rename @extensible into @nonexhaustive
This is an accepted spelling for the attribute. This commit
also renames the feature flag from `ExtensibleAttribute` to
`NonexhaustiveAttribute` to match the spelling of the attribute.

(cherry picked from commit fe1ae75711)
2025-08-18 23:58:27 -07:00
Pavel Yaskevich
cefa0b2fbf [AST/Sema] Add @preEnumExtensibility attribute to downgrade warnings for extensible enums
Just like `@preconcurrency` for concurrency, this attribute is going
to allow exhaustiveness error downgrades for enums that were retroactively
marked as `@extensible`.

(cherry picked from commit 498430afaf)
2025-08-18 23:58:03 -07:00
Pavel Yaskevich
58988a09da [AST] Prevent use of @extensible without ExtensibleAttribute feature
(cherry picked from commit 0ad7d8b590)
2025-08-18 23:57:45 -07:00
Pavel Yaskevich
a0ab1dc40d [Frontend] Add ExtensibleAttribute to guard use of @extensible attribute
Guard against condfails when older compilers get a swift interface
that uses `@extensible` attribute. The attribute itself doesn't
have any effect in swift interfaces yet since all of the public
enums are already resilient in that mode.

(cherry picked from commit 6d89bca765)
2025-08-18 23:57:44 -07:00
Pavel Yaskevich
4579afb71d [Frontend/Serialization] Remove ExtensibleEnums experimental flag
For now the semantics provided by `@extensible` keyword on per-enum
basis. We might return this as an upcoming feature in the future with
a way to opt-out.

(cherry picked from commit bf19481ab6)
2025-08-18 23:57:08 -07:00
Pavel Yaskevich
bcf38a1aef [AST/Sema] Add @extensible attribute on enum declarations
This attribute controls whether cross-module access to the declaration
needs `@unknown default:` because it's allowed to gain new cases even
if the module is non-resilient.

(cherry picked from commit a0ae93d3a8)
2025-08-18 23:56:49 -07:00
Guillaume Lessard
5e9c3f4a1d [stdlib] guard against underflow 2025-08-16 04:13:15 -07:00
Guillaume Lessard
f593d75d04 [test] removeAll() from an empty OutputSpan 2025-08-16 04:13:09 -07:00
nate-chandler
49dbb15f5f Merge pull request #83709 from nate-chandler/cherrypick/release/6.2/rdar157772187
6.2: [SIL] Fix visitAccessedAddress @ end_borrow
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-19-a
2025-08-15 17:12:33 -07:00
Gábor Horváth
88ea7f198d Merge pull request #83692 from Xazax-hun/fix-ref-name-mangling-on-6.2
[6.2][cxx-interop] Fix name mangling for reference types
2025-08-14 20:52:32 +01:00
Gábor Horváth
037e348526 Merge pull request #83691 from Xazax-hun/check-safety-function-types-on-6.2
[6.2][StrictMemorySafety] Check the safety of return types of calls
2025-08-14 20:27:53 +01:00
Doug Gregor
c291adaaa5 Merge pull request #83677 from DougGregor/c-interop-improvements-6.2 2025-08-14 12:13:47 -07:00
Pavel Yaskevich
7df1fe7289 Merge pull request #83698 from xedin/rdar-156955193-6.2
[6.2][TypeCheckEffects] AbstractFunction: Parameter types should be mapped…
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-14-a
2025-08-13 22:34:27 -07:00
nate-chandler
2f34d0a9a5 Merge pull request #83525 from jamieQ/release/6.2
[6.2][SILOptimizer]: fix some missing use after consume diagnostics
2025-08-13 18:14:07 -07:00
Nate Chandler
9178277dbf [InlineArray] Fix outlining metadata collection.
The metadata of the element type is required for outlining.

rdar://158083136
2025-08-13 16:52:26 -07:00
Nate Chandler
c7c0cb03d2 [SIL] Fix visitAccessedAddress @ end_borrow
`end_borrow` instructions may end the scopes introduced by `load_borrow`
or `store_borrow` instructions, or those introduced by `begin_borrow`
whose operand's guaranteed root includes a `load_borrow`.

Previously, such scope ending instructions which end the scope
associated with a borrowing load or store were not regarded as accessing
the loaded-from or stored-to address.  One consequence of this is that
they were not regarded as accessing pointers and thus not as deinit
barriers; that in turn resulted in `destroy_addr`s being hoisted into
such borrow scopes.

Here this is fixed by regarding such `end_borrow`s to access the
loaded-from or stored-to address of the scope-introducing `load_borrow`
or `store_borrow` respectively.

rdar://157772187
2025-08-13 16:48:58 -07:00
Allan Shortlidge
92220f223b Merge pull request #83658 from tshortli/isolated-deinit-inlining-availability-6.2
[6.2] Sema: Fix isolated deinit availability checking
2025-08-13 16:32:37 -07:00
Pavel Yaskevich
7f652915d9 [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)
2025-08-13 10:19:51 -07:00