Commit Graph

47419 Commits

Author SHA1 Message Date
Rintaro Ishizaki
8c798469d1 Merge pull request #84829 from rintaro/plugin-termsignal-rdar160820381
[Macros] Send termination signal to macro plugin
2025-10-13 10:27:47 -07:00
Erik Eckstein
65e4c10113 Optimizer: remove the obsolete SpeculativeDevirtualization pass
This pass has been disabled since a very long time (because it's terrible for code size).
It does not work for OSSA. Therefore it cannot be enabled anymore (as is) once we have OSSA throughout the pipeline.
So it's time to completely remove it.
2025-10-13 10:49:17 +02:00
Tim Kientzle
41f680cb93 Merge pull request #84826 from tbkka/tbkka-revert-revert-floatingpointdescription
Re-land new Floating-poing `debugDescription`
2025-10-12 20:19:12 -07:00
John McCall
46623cb6c7 Merge pull request #84811 from rjmccall/verify-dead-end-edges
Strengthen the SIL verifier's rules for edges into dead-end regions
2025-10-11 18:16:56 -04:00
Slava Pestov
5f897a88a5 Merge pull request #84821 from slavapestov/prepared-diagnostics
Small fixes for diagnostics with prepared overloads enabled
2025-10-11 07:55:18 -04:00
John McCall
90995b82f4 Teach the SIL verifier to enforce stronger rules around
edges into dead-end regions.

- Only treat edges *into* dead-end regions as special; edges internal
  the region must use the normal rules.

- Conservatively merge information along those edges rather than just
  picking one at random. This requires us to not walk into the region
  until we've processed all of the edges to it.

- Make sure we prevent *any* stack allocations from being deallocated
  if the stack is inconsistent entering a block.

Additionally, fix a bug which was incorrectly treating all blocks that
don't themselves exit the function as ultimately leading to unreachable,
which had inadvertently largely turned off the consistency check.
2025-10-11 02:12:19 -04:00
John McCall
c610727e0c Add a utility to simplify making a dynamic choice to move or copy.
Using it with emplacing methods relies on actually have a constructor
that takes maybe_movable_ref<X>, which can be awkward. But there are
cases where just calling construct() explicitly can be helpful.
2025-10-11 02:12:18 -04:00
John McCall
33bf18e3ab Add a utility to check for edges into dead-end regions.
This is subtly different from just checking whether the destination of
an edge is dead-end, because edges *internal* to dead-end regions
generally still need to be treated normally. Fundamentally, such an edge
must be part of a loop.
2025-10-11 02:12:18 -04:00
Michael Gottesman
8686d3fd21 Merge pull request #84830 from gottesmm/pr-280fbe6eca8e73a6caec46dd571aa9afe8bf8b93
[rbi] Cleanup handling of how we send parameters to fix issues with inout sending.
2025-10-10 23:00:06 -07:00
Michael Gottesman
13e8eed3a8 [rbi] Cleanup handling of how we send parameters to fix issues with inout sending.
We previously were not "unsending" inout sending parameters after sending them
so they could not be used again in the caller and could not be forwarded into
other 'inout sending' parameters. While looking at the code I
realized it was pretty obtuse/confusing so I cleaned up the logic and fixed a
few other issues in the process.

Now we follow the following pattern in the non-isolation crossing case:

1. We first require the callee operand.
2. We then merge/require all of the non-explicitly sent parameters.
3. We then through all of the parameters and require/send all of the sending parameters.
4. At the end of processing, we unsend all of the sending parameters that were
'inout sending' parameters.

In the case of isolation crossing applies we:

1. Require all parameters that are not explicitly marked as sending and then
send them all at once. We are really just saving a little work by not merging
them into one large region and then requiring/sending that region once.

2. Then for each sending parameter, we require/send them one by one interleaving
the requires/sends. This ensures that if a value is passed to different
explicitly sending parameters, we get an error.

3. Then once we have finished processing results, we perform an undo send on all
of the 'inout sending' params.

rdar://154440896
2025-10-10 15:58:11 -07:00
Rintaro Ishizaki
a0b9b54944 [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
2025-10-10 15:13:13 -07:00
Pavel Yaskevich
243f550b80 Merge pull request #84777 from xedin/tilde-sendable
[AST/Sema] Implement `~Sendable` support behind an experimental feature flag
2025-10-10 14:27:20 -07:00
Tim Kientzle
4c0b58096e Make _InlineArray subject to the same optimizations as InlineArray 2025-10-10 14:06:14 -07:00
Slava Pestov
8600cdcc2a Sema: Remove ConstraintSystemPhase::{Diagnostics,Finalization} 2025-10-10 16:06:42 -04:00
Slava Pestov
a8d896ab8f Sema: Don't reuse PreparedOverload from normal type checking in salvage()
We want to re-prepare our overloads, since now they will contain fixes.
2025-10-10 15:44:12 -04:00
Slava Pestov
036db6fb08 Sema: Only use PreparedOverload::Change::AddedBindConstraint if the locator didn't change
For a Bind constraint generated by a same-type requirement, we must
preserve the locator so we need to record it like any other kind of
constraint.

This fixes a diagnostic regression with -solver-enable-prepared-overloads.
2025-10-10 15:33:31 -04:00
Doug Gregor
ce5b1a126d Merge pull request #84392 from rjmansfield/sil-ir-extra-outputs
Add frontend options to write SIL and LLVM IR as additional compilation output
2025-10-10 12:09:38 -07:00
Hamish Knight
b648818fb5 Merge pull request #84804 from hamishknight/is-bare
[AST] Simplify `Type::isBareErrorType`
2025-10-10 17:26:29 +01:00
Hamish Knight
1c18541479 [AST] Simplify Type::isBareErrorType
Missed this when I changed `ErrorType::get` to flatten nested
ErrorTypes on construction, we no longer need to check for the
recursive case here.
2025-10-10 12:13:36 +01:00
Andrew Trick
d653b0ccd0 Merge pull request #84739 from atrick/lifedep-unsafeaddress
LifetimeDependenceDefUseWalker: store to unsafeMutableAddress
2025-10-09 18:40:32 -07:00
Chirag Ramani
5179bc9609 Add IRPGO and CSIRPGO options to Swift (#84335)
This PR introduces three new instrumentation flags and plumbs them
through to IRGen:

1. `-ir-profile-generate` - enable IR-level instrumentation.
2. `-cs-profile-generate` - enable context-sensitive IR-level
instrumentation.
3. `-ir-profile-use` - IR-level PGO input profdata file to enable
profile-guided optimization (both IRPGO and CSIRPGO)

**Context:**
https://forums.swift.org/t/ir-level-pgo-instrumentation-in-swift/82123

**Swift-driver PR:** https://github.com/swiftlang/swift-driver/pull/1992

**Tests and validation:**
This PR includes ir level verification tests, also checks few edge-cases
when `-ir-profile-use` supplied profile is either missing or is an
invalid IR profile.

However, for argument validation, linking, and generating IR profiles
that can later be consumed by -cs-profile-generate, I’ll need
corresponding swift-driver changes. Those changes are being tracked in
https://github.com/swiftlang/swift-driver/pull/1992
2025-10-09 17:41:47 -07:00
Pavel Yaskevich
9d1df1f68b [Sema] Expand ~Sendable annotation checking and diagnostics
Diagnose incorrect conformance + suppression uses, make sure
that adding `Sendable` is not suggested is type is using `~Sendable`.
2025-10-09 13:46:01 -07:00
Pavel Yaskevich
93961aa5a2 [AST] Implement printing suppression for ~Sendable 2025-10-09 13:45:55 -07:00
Slava Pestov
804c1f9dd1 Merge pull request #84771 from slavapestov/fix-rdar131832797
SIL: The inner type of a SILMoveOnlyWrappedType is a lowered position
2025-10-09 14:32:58 -04:00
Pavel Yaskevich
c50602b2ce [Sema] Diagnose invalid uses of protocol suppression via ~ syntax 2025-10-09 10:41:27 -07:00
Pavel Yaskevich
389c240a2a [AST] Mark Sendable as a repressible protocol
This allows to spell `~Sendable` to suppress the conformance
inference on types when `TildeSendable` flag is enabled.
2025-10-09 10:41:27 -07:00
Pavel Yaskevich
1ac87e7004 [Basic] Add an experimental feature flag to guard use of ~Sendable 2025-10-09 10:41:25 -07:00
Hamish Knight
a83ea3c8bb Merge pull request #84745 from hamishknight/fishmonger
[Evaluator] Enforce consistent results for cyclic requests
2025-10-09 17:08:04 +01:00
Allan Shortlidge
b9fd3e4604 Merge pull request #84778 from tshortli/swift-runtime-availability-domain
AST: Introduce a Swift runtime availability domain
2025-10-09 08:53:20 -07:00
Slava Pestov
f2615c131f Merge pull request #84765 from slavapestov/fix-rdar161968922
SIL: Fix crash in remapParentFunction() due to missing generic signature
2025-10-09 09:00:42 -04:00
Slava Pestov
47049ce5fe Merge pull request #84299 from slavapestov/non-canonical-archetypes
AST: Allow non-canonical opaque archetypes
2025-10-09 01:04:02 -04:00
Kavon Farvardin
a528c5c19c Merge pull request #84734 from kavon/opaque-values/fixes-2
OpaqueValues: support typed throws
2025-10-08 21:17:23 -07:00
Allan Shortlidge
1a86cd9c26 AST: Introduce a Swift runtime availability domain.
Add support for the `Swift` availability domain, which represents availability
with respect to the Swift runtime. Use of this domain is restricted by the
experimental feature `SwiftRuntimeAvailability`.
2025-10-08 17:31:57 -07:00
Pavel Yaskevich
1d8536eed2 Merge pull request #84729 from xedin/rdar-161207705
[CSSimplify] Avoid simplifying dependent members until pack expansion…
2025-10-08 16:19:00 -07:00
Kavon Farvardin
3b0e77390e AddressLowering: support typed throws
Out of SILGen, we'll get the non-indirect SSA for throwing
the error. AddressLowering then converts a `throw` into
`throw_addr` to match the function convention. Similarly, a
try_apply gets rewritten to pass the error address to the
error successor block.

resolves rdar://158171053
2025-10-08 15:59:13 -07:00
Allan Shortlidge
2d8465b043 AST: Introduce the SwiftLanguageMode availability domain spelling.
Require `-enable-experimental-feature SwiftRuntimeAvailability` to use this new
spelling.
2025-10-08 15:46:34 -07:00
Allan Shortlidge
4e9a883824 AST: Rename SwiftLanguage availability domain kind to SwiftLanguageMode. 2025-10-08 15:46:34 -07:00
Hamish Knight
57557dec8e [Evaluator] Enforce consistent results for cyclic requests
Record when we encounter a request cycle, and enforce that the outer
step of the cycle also returns the default value. This fixes a couple
of crashers where we were ending up with conflicting values depending
on whether the request was queried from within the cycle or from
outside it.
2025-10-08 21:16:02 +01:00
Hamish Knight
f7e459a9b5 [AST] Factor out GenericSignature::forInvalid
Factor out the common logic from `getPlaceholderGenericSignature`.
2025-10-08 21:16:02 +01:00
Anthony Latsis
537353074d Merge pull request #84730 from swiftlang/jepa-main2
RequirementMachine: Diagnose unsupported value generic parameter definitions properly
2025-10-08 21:12:00 +01:00
Slava Pestov
6e53f8c974 SIL: Fix crash in remapParentFunction() due to missing generic signature
We need to pass down the generic signature of the caller to correctly
mangle the substitution map, because the replacement types in this
substitution maps are interface types for the caller's generic signature.

Fixes rdar://problem/161968922.
2025-10-08 15:56:49 -04:00
Slava Pestov
b55a141d7b SIL: Upgrade assert() to ASSERT() 2025-10-08 15:53:48 -04:00
Slava Pestov
8cf491f825 AST: Allow non-canonical opaque archetypes 2025-10-08 15:15:50 -04:00
Slava Pestov
0d90b62491 AST: Clean up in preparation for non-canonical archetypes 2025-10-08 15:15:43 -04:00
Meghana Gupta
5e325632ed Merge pull request #84746 from meg-gupta/mutateaccessorspr
Add support for mutate accessors
2025-10-08 11:08:59 -07:00
Gábor Horváth
7159b12936 Merge pull request #83752 from Xazax-hun/fix-inline-namespaces
[cxx-interop] Support calling functions in inline namespaces
2025-10-08 18:41:38 +01:00
Artem Chikin
38a8b07ac3 Merge pull request #84684 from aviralg/perf-hint/existential-any
[Performance Hints] Implement check for existential any
2025-10-08 00:19:53 -04:00
Doug Gregor
70f3b2ef9c Merge pull request #84752 from DougGregor/nonunique-linkonce 2025-10-07 21:19:33 -07:00
Anthony Latsis
58fa8bf762 RequirementMachine: Diagnose unsupported value generic parameter definitions properly
The flow was such that we recorded subtype constraints regardless of the
subject type's nature. Extract value generics handling out of the
devious `else if` chain, and never record any subtype constraints if the
subject type is a non-type parameter.

While we're here, generalize the diagnostic message for user-written
subtype constraints on value generic parameters and emit it
consistently, not just if the right-hand side contains a protocol type.
2025-10-08 02:13:03 +01:00
Doug Gregor
4952a2c9ef [Embedded] Prefer linkonce_odr to weak_odr for nonunique definitions
This allows the implementation to drop definitions that it does need.
2025-10-07 14:57:31 -07:00