Commit Graph

184412 Commits

Author SHA1 Message Date
Erik Eckstein
2f1e761c90 benchmark script tests: make the match string for invalid option errors more flexible
Because the actual output depends on the python version

(cherry picked from commit ce86f65272)
2025-11-04 09:00:28 -08:00
Adrian Prantl
49953edce0 Merge pull request #85195 from augusto2112/remote-mirr-indirect-addr-6.2
[RemoteMirrors] Add hook for resolving indirect addresses
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-10-31-a swift-6.2-DEVELOPMENT-SNAPSHOT-2025-11-01-a swift-6.2-DEVELOPMENT-SNAPSHOT-2025-11-03-a
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
Alastair Houghton
678ec6ec60 Merge pull request #85152 from al45tair/eng/PR-163386438
Make the _Concurrency library depend on _Builtin_float
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-10-28-a swift-6.2-DEVELOPMENT-SNAPSHOT-2025-10-30-a
2025-10-28 10:43:54 +00:00
Allan Shortlidge
13816faef3 Merge pull request #85159 from tshortli/suppress-inherited-retroactive-conformance-diags-with-module-qualification-6.2
[6.2] Sema: Fix a regression in retroactive conformance diagnostic suppression
2025-10-27 20:11:32 -07:00
Allan Shortlidge
60c711d4a6 Sema: Fix a regression in retroactive conformance diagnostic suppression.
Module qualifying a protocol name in an inheritance clause should suppress
retroactive conformance diagnostics for the protocol and any protocols it
inherits from, just like adding the `@retroactive` attribute. Fixes a
regression in Swift 6.2 introduced by
https://github.com/swiftlang/swift/pull/81576.

Resolves rdar://162295268 and https://github.com/swiftlang/swift/issues/85153.
2025-10-27 11:34:25 -07:00
Doug Gregor
5464841e90 Make the _Concurrency library depend on _Builtin_float
rdar://163386438
2025-10-27 15:17:02 +00:00
Kavon Farvardin
8c1cc1b78a Merge pull request #85120 from kavon/6.2-fspl-debuginfo-rdar163281183
[6.2] DebugInfo: fix FSPL SILLocation assertion issue
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-10-25-a
2025-10-25 01:30:47 -07:00
Michael Gottesman
c6314a37b0 Merge pull request #84986 from gottesmm/release/6.2-rdar156525771
[6.2] Add support for TBI masking optimization for nonisolated(nonsending)
2025-10-24 15:31:26 -07:00
Kavon Farvardin
e6694c124e DebugInfo: fix FSPL SILLocation assertion issue
We were reusing the SILLocation from return instructions
to generate projections to ultimately destroy values.

This fix improves on what we were doing before, by
converting the insertion point's SILLocation into a
RegularLocation _without dropping_ the source location.

If the SILLocation was tied to an ASTNode, it'll carry
over the line location for this new regular location.
Otherwise, it'll fallback to the prior strategy of
producing a line 0 autogenerated location.

resolves rdar://163281183

(cherry picked from commit fd06bb1eeb)
2025-10-24 12:08:07 -07:00
eeckstein
de48c2f59b Merge pull request #84946 from eeckstein/fix-simplify-cfg-6.2
[6.2] SimplifyCFG: insert compensating destroy when replacing a `switch_enum`
2025-10-23 20:47:01 +02:00
Erik Eckstein
c4c1c50e73 SimplifyCFG: insert compensating end_lifetime when replacing a switch_enum
This is a follow-up of https://github.com/swiftlang/swift/pull/84905, which handles non-copyable enums with a deinit correctly.
Also, for copyable enums it's more efficient to use `end_lifetime` than `destroy_value`, because we already know that the enum contains a trivial case.
Therefore no destroy operation is needed.
2025-10-23 08:18:04 +02:00
Erik Eckstein
ffc71e95e8 SimplifyCFG: insert compensating destroy when replacing a switch_enum
When replacing a `switch_enum` of an owned enum value with a branch to a non-payload case destination,
we need to insert a destroy of the enum value.

Fixes a SIL ownership verification failure.
https://github.com/swiftlang/swift/issues/84552
rdar://161482601
2025-10-23 08:17:12 +02:00
Michael Gottesman
8e3fa552dc Fix a concurrency irgen test for differences between main and release/6.2 2025-10-17 13:36:24 -07:00
Michael Gottesman
abc2e304dc Small fix for type with different name on 6.2. 2025-10-17 11:40:50 -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
f8ec8ac314 Test updates for previous commit.
(cherry picked from commit dc193063cf)

Conflicts:
	test/Concurrency/isolation_macro_sil.swift
	test/Concurrency/nonisolated_nonsending_optimize_hoptoexecutor.swift
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
f625cce668 [concurrency] NFC refactor out some code from LowerHopToActor before changing the pass.
Specifically, I am refactoring out the code that converts actor/Optional<any
Actor> to an executor in preparation for adding code to LowerHopToExecutor that
handles Builtin.ImplicitIsolationActor.

The only actual functional change is that I made getExecutorForOptionalActor
support being invoked when generating code (i.e. when its SILBuilder has an
insertion point at the end of the block). It previously assumed that it would
always have a real SILInstruction as an insertion point. The changes can be seen
in the places where we now check if the insertion point equals the end of a
block. Its very minor and due to conditional control flow doesn't have any
actual impact given the manner that the code today is generated. This came up in
a subsequent commit when I reuse this code to generate a helper function for
converting Builtin.ImplicitIsolationActor to Builtin.Executor.

(cherry picked from commit 21915ae428)

Conflicts:
	lib/SILOptimizer/Mandatory/LowerHopToActor.cpp
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
40392258a6 [silgen] Change two places we used Builtin.Executor to instead use Optional<any Actor> as an expected executor.
We want SILGen to have a simplified view of its executor and know that whenever
one sees an Actor, it is an actual actor instead of a Builtin.Executor. This
just simplifies code. Also, we should eventually have an invariant that
Builtin.Executor should only be allowed in LoweredSIL after LowerHopToExecutor
has run. But that is a change for another day.

(cherry picked from commit 81885a67d0)
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
bf524c4fca [sil-llvm-gen] Run Sema before we attempt to emit IR.
(cherry picked from commit 3a96e99bd8)
2025-10-17 11:33:27 -07:00
Michael Gottesman
2e7c74c102 [sil-llvm-gen] Allow for -Xllvm options to be passed to sil-llvm-gen.
Specifically, we ignore the -Xllvm bit and put the option into
FrontendOptions.LLVMArgs so that parts of CompilerInvocation that assumes that
-Xllvm flags will be placed there are actually there. We still pass through the
argument to llvm::cl so it gets set that way as well.

(cherry picked from commit d0d2163e0d)
2025-10-17 11:33:27 -07:00
Michael Gottesman
c86902d342 [sil-llvm-gen] Update some settings setup from sil-opt.
(cherry picked from commit ca2fb094d2)
2025-10-17 11:33:27 -07:00
Michael Gottesman
d7e41d2d9b [sil-llvm-gen] Add support for emitting IR before LLVM optimizations run.
Specifically, I renamed the old llvm-as which printed with optimization as
llvm-as-opt and made llvm-as just test IRGen. That is really the true reason
that I created this utility many years ago: to test how IRGen lowers specific
SIL instruction sequences. How LLVM optimizes such sequences once lowered is a
different problem. I updated the one test that used sil-llvm-gen and required
optimizations to use llvm-as-opt so that the tests output did not change.

(cherry picked from commit 5c8a95f27a)
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
Michael Gottesman
b4c3a212f4 [ast] Convert swift::getBuiltinType to use a covered switch for BuiltinTypeKind.
This is an NFC change. The idea is that this will make it easier to add new
BuiltinTypeKinds. I missed this code when adding Builtin.ImplicitIsolationActor.
By adding a covered switch, we can make sure this code is updated in the
future.

(cherry picked from commit 05536d7183)
2025-10-17 11:33:27 -07:00
Hamish Knight
d7bb1fe25f Merge pull request #84965 from hamishknight/quick-fix-6.2
[6.2] [Sema] Quick fix for non-copyable type resolution crash
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-10-18-a swift-6.2-DEVELOPMENT-SNAPSHOT-2025-10-21-a swift-6.2-DEVELOPMENT-SNAPSHOT-2025-10-20-a swift-6.2-DEVELOPMENT-SNAPSHOT-2025-10-23-a swift-6.2-DEVELOPMENT-SNAPSHOT-2025-10-22-a
2025-10-17 05:38:29 +01:00
Hamish Knight
7629fbd0e0 [Sema] Quick fix for non-copyable type resolution crash
Add a guard to make sure we don't attempt to check for Copyable
conformance if the type contains type variables. This matches the
existing behavior where we won't check for unbound generic types.
Neither behavior is correct since we won't do the proper check once
the generic type is opened, but this at least makes the behavior
consistent and fixes the crash. It's also a very low risk fix that
can be cherry-picked.

rdar://152287178
2025-10-16 20:34:38 +01:00
Kavon Farvardin
24154e3638 Merge pull request #84937 from kavon/6.2-the-realloc-strikes-back-rdar162440304
[6.2] MoveOnlyChecker: avoid dangling reference in custom alloc
2025-10-16 12:22:05 -07:00
Guillaume Lessard
f449b7bcc1 Merge pull request #84894 from hnrklssn/revert-span-for-libstdc++
[6.2] Revert "add std::span to module map for libstdc++"
2025-10-16 08:16:50 -07:00
Kavon Farvardin
743599b765 MoveOnlyChecker: avoid dangling reference in custom alloc
The AvailableValueStore maintains stable spans of SILValues,
one span (effectively a MutableArrayRef) per basic block, that
is preallocated for performance.

This patch fixes an issue where _a pointer_ to a span is vended from
`AvailableValueStore::get` and that pointer is into storage within
a DenseMap, which can reallocate and invalidate all such pointers.

There's no reason to be returning a pointer to a MutableArrayRef,
aka AvailableValues, so I've simply stripped off that indirection to
fix this issue.

resolves rdar://162440304

(cherry picked from commit d1f3f8495e)
2025-10-15 15:03:42 -07:00
Henrik G. Olsson
2afd4ec7a4 Revert "add std::span to module map for libstdc++"
This reverts commit f7d5902db5.

It was part of a larger PR in
https://github.com/swiftlang/swift/pull/84755, but turned out to be
broken for older versions of libstdc++. Since it's not critical to the
functionality of the larger PR, this reverts the problematic part.

rdar://161999183
2025-10-15 13:52:31 -07:00
Anthony Latsis
69a38d9382 Merge pull request #84885 from swiftlang/jepa-release
[6.2] Disable std-span-interface.swift test (161999174)
2025-10-14 18:54:28 +01:00
Rintaro Ishizaki
13a49c9e19 Merge pull request #84844 from rintaro/6.2-plugin-termsignal-rdar160820381
[6.2][Macros] Send termination signal to macro plugin
2025-10-13 21:31:27 -07:00
Mishal Shah
5c4e6fcab7 Disable std-span-interface.swift test (161999174) 2025-10-14 03:29:43 +01: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
Gábor Horváth
bf2671510d Merge pull request #84768 from Xazax-hun/fix-overrelease-destroy-hoist-on-6.2
[6.2][cxx-interop] Delay lowering unowned convention until ownership elimination
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-10-09-a
2025-10-09 02:40:33 +01:00
nate-chandler
b5fed1546e Merge pull request #84763 from nate-chandler/cherrypick/release/6.2/rdar161606892_2
6.2: [VariadicGenerics] Fix memeffect of metadata accessor.
2025-10-08 15:36:36 -07:00
John McCall
d42b260497 Merge pull request #84732 from rjmccall/variadic-witness-fixes-6.2
[6.2] Fix some major SILGen bugs with pack handling:
2025-10-08 16:35:09 -04:00
Gábor Horváth
40bea13e68 [6.2][cxx-interop] Delay lowering unowned convention until ownership elimination
Explanation: Unowned result conventions do not work well with OSSA. Retain the
result right after the call when we come out of OSSA so we can treat the
returned value as if it was owned when we do optimizations.

This fix a miscompilation due to the DestroyAddrHoisting pass hoisting destroys
above copies with unowned sources. When the destroyed object was the last
reference to the pointed memory the copy is happening too late resulting in
a use after free.

Issues: rdar://160462854
Original PRs: #84612
Risk: We change where retaining of the unowned return values
happen in the optimization pipeline. It is hard to anticipate all the
possible effects but it should make the optimizer more correct.
Testing: Added a compiler test.
Reviewers: @eeckstein, @atrick
2025-10-08 18:57:54 +01:00
Henrik G. Olsson
d1dbf8e3bb complete availability 2025-10-08 09:26:01 -07:00
Alejandro Alonso
2a18def9a5 Merge pull request #84749 from Azoy/62-sext-instead-of-zext
[6.2] [IRGen] Correctly sext instead of zext for negative integer types
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-10-08-a
2025-10-08 08:03:43 -07:00
Alejandro Alonso
4fb9e6e1de Merge pull request #84748 from Azoy/62-deserialization-issue
[6.2] [Serialization] Serialize isAddressable on param decls
2025-10-08 08:03:15 -07:00
Nate Chandler
dab39bbf91 [VariadicGenerics] Fix memeffect of metadata accessor call.
Follow up to https://github.com/swiftlang/swift/pull/84635/.

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 the call to any such accessor is not correctly
annotated memory(none).

rdar://161606892
2025-10-08 06:50:04 -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
d983f30cd3 comment test cases unsupported in Swift 6.2 2025-10-08 00:30:28 -07:00