Commit Graph

46002 Commits

Author SHA1 Message Date
Adrian Prantl
49953edce0 Merge pull request #85195 from augusto2112/remote-mirr-indirect-addr-6.2
[RemoteMirrors] Add hook for resolving indirect addresses
2025-10-31 13:58:10 -07:00
Augusto Noronha
98a0a3fcac [RemoteMirrors] Add hook for resolving indirect addresses
Adds a hook so implementations of memory reader can add logic to
resolving remote addresses. This is needed because of an interaction
between LLDB, which tries to read memory from files instead of process
memory whenever possible and the DYLD shared cache.

The shared cache will merge pointers in the GOT sections from multiple
images into one location, and update the relative offsets to point to
the new location.
LLDB, will have initially read the offset pointing to the "old"
location, which will be zeroed out in live memory. This gives LLDB the
opportunity to re-read the relative offset, but from live memory, so it
can return the right pointer in the shared cache.

(cherry picked from commit 0f4a3ceb67a3669cd5433d5ae13fec6852876173)

rdar://163652093
2025-10-29 10:14:08 -07:00
Michael Gottesman
8519540633 [concurrency] Implement bit masking for TBI when available or in tagged pointer bits otherwise.
Specifically, when TBI is available we use the bottom two bits of the top nibble
(bits 60,61). On platforms without TBI, we use the bottom two tagged pointer
bits (bits 0, 1).

rdar://156525771
(cherry picked from commit 390afe3e7d)
2025-10-17 11:33:27 -07:00
Michael Gottesman
ce162afd9d [silgen] Use Builtin.ImplicitActor instead of Optional<any Actor> to represent the implicit isolated parameter.
NOTE: We are not performing any bitmasking at all now. This is so that we can
transition the code base/tests to expect Builtin.ImplicitActor instead
of Optional<any Actor>.

NOTE: The actual test changes are in the next commit. I did this to make it
easier to review the changes.

This should not have any user visible changes.

(cherry picked from commit 788abd0b96)
2025-10-17 11:33:27 -07:00
Michael Gottesman
380e414a35 [sil] Add a new instruction cast_implicit_actor_to_optional_actor.
This instruction converts Builtin.ImplicitActor to Optional<any Actor>. In the
process of doing so, it masks out the bits we may have stolen from the witness
table pointer of Builtin.ImplicitActor. The bits that we mask out are the bottom
two bits of the top nibble of the TBI space on platforms that support TBI (that
is bit 60,61 on arm64). On platforms that do not support TBI, we just use the
bottom two tagged pointer bits (0,1).

By using an instruction, we avoid having to represent the bitmasking that we are
performing at the SIL level and can instead just make the emission of the
bitmasking an IRGen detail. It also allows us to move detection if we are
compiling for AArch64 to be an IRGen flag instead of a LangOpts flag.

The instruction is a guaranteed forwarding instruction since we want to treat
its result as a borrowed projection from the Builtin.ImplicitActor.

(cherry picked from commit fe9c21fd87)
2025-10-17 11:33:27 -07:00
Michael Gottesman
a4dca2545b [concurrency] Add a new type Builtin.ImplicitActor.
This is currently not wired up to anything. I am going to wire it up in
subsequent commits.

The reason why we are introducing this new Builtin type is to represent that we
are going to start stealing bits from the protocol witness table pointer of the
Optional<any Actor> that this type is bitwise compatible with. The type will
ensure that this value is only used in places where we know that it will be
properly masked out giving us certainty that this value will not be used in any
manner without it first being bit cleared and transformed back to Optional<any
Actor>.

(cherry picked from commit 2fa3908e94)

Conflicts:
	lib/AST/ASTPrinter.cpp
	lib/IRGen/IRGenModule.cpp
2025-10-17 11:33:27 -07:00
Michael Gottesman
605437ab18 [irgen] Make HasAArch64TBI an IRGen option instead of a LangOpts.
With some changes that I am making, we will no longer need this flag at the SIL
level, so we can just make it an IRGen flag (which it really should have been
in the first place).

(cherry picked from commit 361e63c815)
2025-10-17 11:33:27 -07:00
Michael Gottesman
7fcc8a5460 [frontend] Expose via a LangOption whether or not the compiler is compiling for a triple that supports AArch64 TBI.
Just breaking down layers of a larger patch to make it easier to review.

(cherry picked from commit bfecaa357f)
2025-10-17 11:33:27 -07:00
Rintaro Ishizaki
f735928597 [Macros] Send termination signal to macro plugin
When shutting down, the plugin, we send SIGTERM, then wait(2) on it. But
we observed some cases the compiler waits for the plugin process exit
for long time.

To resolve that, send an empty message to the plugin and let them exit
itself.

rdar://160820381
(cherry picked from commit a0b9b54944)
2025-10-12 22:06:16 -07:00
Henrik G. Olsson
d00f711af7 Merge pull request #84755 from hnrklssn/cherry-pick-swiftify-import-as-method-6.2
Cherry-pick [6.2] [Swiftify] Add support for free functions imported as instance methods
2025-10-10 11:00:06 -07:00
Nate Chandler
9ab224212e [VariadicGenerics] Fix memeffect of metadata accessor.
The metadata accessor for a variadic generic type takes as arguments
packs of metadata records and witness tables, and each such pack is
passed in a buffer.  So any such accessor is not correctly annotated
`memory(none)`.

rdar://161606892
2025-10-08 06:50:04 -07:00
Henrik G. Olsson
6a9ac22cd2 Merge pull request #84507 from hnrklssn/swiftify-import-as-method
[Swiftify] Add support for free functions imported as instance methods

(cherry picked from commit ed4f058c01)
2025-10-07 20:12:44 -07:00
Egor Zhdan
c5c33d6c5a [cxx-interop] Allow retain/release operations to be methods
Some foreign reference types such as IUnknown define retain/release operations as methods of the type.

Previously Swift only supported retain/release operations as standalone functions.

The syntax for member functions would be `SWIFT_SHARED_REFERENCE(.doRetain, .doRelease)`.

rdar://160696723
(cherry picked from commit e78ce6165f)
2025-09-23 14:45:41 +01:00
John McCall
df7cfbfbc1 Add a function for querying the isolation of an Initializer. 2025-09-11 21:52:13 -04:00
John McCall
a6c40c75c8 Fix two bugs with the isolation of defer bodies.
The first bug is that we weren't computing isolation correctly for
nested defers. This is an unlikely pattern of code, but it's good to fix.

The second bug is that getActorIsolationOfContext was looking through
defers, but getActorIsolation itself was not. This was causing defer
bodies to be emitted in SILGen without an isolation parameter, which
meant that #isolation could not possibly provide the right value. Fixing
this involves teaching SILGen that non-async functions can have
nonisolated(nonsending) isolation, but that's relatively straightforward.

This commit doesn't fix #isolation or adequately test SILGen, but that'll
be handled in a follow-up.
2025-09-11 21:52:03 -04:00
John McCall
6f376c2468 Fix SILGen's computation of default argument generator isolation 2025-09-11 21:51:36 -04:00
John McCall
f72fd5aa8f Merge pull request #82930 from nickolas-pohilets/mpokhylets/6.2-weak-let
[6.2] Cherry-pick SE-0481 with source-incompatible changes to closure capture semantics still wrapped into a feature
2025-09-11 20:02:39 -04:00
Charles Zablit
74aed83b30 [demangling] make printRoot virtual 2025-09-10 11:34:51 +01:00
Artem Chikin
fdaafd6a10 Merge pull request #84089 from artemcm/62_DepScanWorkersNoShareDiagEngine
[6.2 🍒][Dependency Scanning] Give each scanner worker a unique Diagnostic Engine
2025-09-04 12:42:42 -04:00
Gábor Horváth
f114a1e60f Merge pull request #84053 from Xazax-hun/attr-hide-swift-decls-on-6.2
[cxx-interop] Add attribute to hide Swift declarations from interop
2025-09-04 10:37:36 +01:00
Artem Chikin
0fa722f41f [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 13:55:02 -07:00
Charles Zablit
34db9e8d2e [demangling] make printGenericSignature virtual
(cherry picked from commit 6324f20318)
2025-09-02 15:20:25 -07:00
eeckstein
90e245a840 Merge pull request #84006 from eeckstein/fix-array-property-opt-6.2
[6.2] Optimizer: fix an ownership violation when duplicating loops
2025-09-02 18:52:35 +02:00
Gábor Horváth
fa65cc9b2b [cxx-interop] Add attribute to hide Swift declarations from interop
Explanation: We generate declarations in the C++ interop header with
"unavailable" annotations when we cannot export something to C++. These
declarations can collide with existing names. Previously, there were no
ways to resolve these name collisions. This PR introduces a new
attribute to hide declarations from the interop header.
Issues: rdar://158843666
Original PRs: #82616
Risk: Low, this adds a new, straightforward code path.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-09-02 13:28:27 +01:00
Alejandro Alonso
f15d600460 Merge pull request #83953 from Azoy/62-extended-existentials
[6.2] [AST & Runtime] Correctly mangle extended existentials with inverse requirements
2025-08-30 11:10:21 -07:00
Erik Eckstein
9081edd4c2 Optimizer: fix an ownership violation when duplicating loops
If a guaranteed value is used in a dead-end exit block and the enclosing value is _not_ destroyed in this block, we end up missing the enclosing value as phi-argument after duplicating the loop.
TODO: once we have complete lifetimes we can remove this check again.

rdar://159125605
2025-08-29 17:28:57 +02: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.
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
Alejandro Alonso
0877b04efe Merge pull request #81365 from Azoy/my-existentials
[AST & Runtime] Correctly mangle extended existentials with inverse requirements
2025-08-27 10:00:59 -07: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
Mykola (Nickolas) Pokhylets
5d70bea757 Cherry-pick SE-0481 with source-incompatible changes to closure capture semantics still wrapped into a feature
See https://github.com/swiftlang/swift/pull/80440 and https://github.com/swiftlang/swift/pull/82732
2025-08-22 10:31:42 +02: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
2025-08-20 02:58:41 +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
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
Doug Gregor
c291adaaa5 Merge pull request #83677 from DougGregor/c-interop-improvements-6.2 2025-08-14 12:13:47 -07:00
Artem Chikin
fe4880072e Merge pull request #82939 from artemcm/62_DepScanExplicitInput
[6.2 🍒][Dependency Scanning] Consider `-swift-module-file` inputs when looking for dependencies
2025-08-12 23:00:13 -07:00
Anthony Latsis
9caa4a324a AST: Cut down on DescriptiveDeclKind usage in DiagnosticsClangImporter.def
(cherry picked from commit cdb2aaccfd)
2025-08-12 12:31:33 -07:00
Crazy凡
21f23dcebb [c++ interop] Swift should allow multiple SWIFT_CONFORMS_TO_PROTOCOL attributes on a C++ class.
(cherry picked from commit c05d1fc135)
2025-08-12 12:19:59 -07:00
Egor Zhdan
7a67b350e9 [cxx-interop] Enable foreign reference types in C interop
Most of the logic for C++ foreign reference types can be applied to C types as well. Swift had a compiler flag `-Xfrontend -experimental-c-foreign-reference-types` for awhile now which enables foreign reference types without having to enable C++ interop. This change makes it the default behavior.

Since we don't expect anyone to pass `experimental-c-foreign-reference-types` currently, this also removes the frontend flag.

rdar://150308819
(cherry picked from commit 9178af3ec7)
2025-08-12 11:22:27 -07:00