Commit Graph

47375 Commits

Author SHA1 Message Date
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
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
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
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
Meghana Gupta
b5d15ae3da Update type checking for mutate accessors 2025-10-07 14:12:08 -07:00
Meghana Gupta
c9a68d1e18 Add a new bit to ExtInfo to represent inout results
Move NumParams from ExtInfo to AnyFunctionType to make room in ExtInfo
2025-10-07 14:11:58 -07:00
Becca Royal-Gordon
60b3b088d5 Merge pull request #84358 from beccadax/common-concurrency 2025-10-07 12:21:50 -07:00
Hamish Knight
11d299c212 Merge pull request #84698 from hamishknight/carousel
[Evaluator] Avoid emitting duplicate "through reference here" notes
2025-10-07 20:14:52 +01:00
Aviral Goel
1cf692f116 [Performance Hints] Implement check for existential any
This commit introduces a performance hint check that warns on the use of
existential any in variable declarations, function and closure parameters and
returns, and typealiases.
2025-10-07 11:18:31 -07:00
John Hui
312caa3a82 Merge pull request #84723 from j-hui/suppress-notes
[Diagnostics] Add -suppress-notes flag
2025-10-07 11:18:22 -07:00
Max Desiatov
b545a28bd3 Add missing // REQUIRES: swift_feature_ForExpressions 2025-10-07 12:34:49 +01:00
Gabor Horvath
0e56809834 [cxx-interop] Support calling functions in inline namespaces
The overload resolution generated a constraint that tried to bind
outer.inline_inner to outer. This constraint failed. This PR attempts to
recognize this scenario and make the constraint succeed.

rdar://158401346
2025-10-07 11:39:07 +01:00
Max Desiatov
e7aac5df12 for expressions scaffolding, making constraints work 2025-10-07 11:16:54 +01:00
Pavel Yaskevich
c278717887 [CSSimplify] Avoid simplifying dependent members until pack expansions in the based are bound
Dependent members cannot be simplified if base type contains unresolved
pack expansion type variables because they don't give enough information
to substitution logic to form a correct type. For example:

```
protocol P { associatedtype V }
struct S<each T> : P { typealias V = (repeat (each T)?) }
```

If pack expansion is represented as `$T1` and its pattern is `$T2`, a
reference to `V` would get a type `S<Pack{$T}>.V` and simplified version
would be `Optional<Pack{$T1}>` instead of `Pack{repeat Optional<$T2>}`
because `$T1` is treated as a substitution for `each T` until bound.

Resolves: rdar://161207705
2025-10-07 00:20:51 -07:00
Henrik G. Olsson
3bc17bdd2f Merge pull request #84722 from hnrklssn/conditional-span-module-map
Move `span` to conditional header in libstdc++ module map
2025-10-06 22:09:07 -07:00
eeckstein
401a2ac2bc Merge pull request #84704 from eeckstein/closure-specialization
ClosureSpecialization: support for OSSA and a big overhaul
2025-10-07 06:59:08 +02:00
Hamish Knight
9883477c02 Merge pull request #84699 from hamishknight/meta-error
[CS] Improve diagnostics for non-metatype `type(of:)` contextual type
2025-10-07 02:49:10 +01:00
Henrik G. Olsson
d3214de950 Merge pull request #84685 from hnrklssn/verify-all
This adds the -verify-ignore-unrelated flag. When -verify is used without -verify-ignore-unrelated, diagnostics emitted in buffers other than the main file and those passed with -verify-additional-file (except diagnostics emitted at <unknown>:0) will now result in an error. They were previously ignored. The old behaviour is still available as opt-in using -verify-ignore-unrelated, but by being strict by default it should make it harder to accidentally miss diagnostics.

To avoid unnecessary performance overhead, -verify-additional-file is still required to parse the expected-* directives in files other than the main file.
2025-10-06 18:01:47 -07:00
John Hui
d68ca8de1e [Diagnostics] Add -suppress-notes flag
We already have -suppress-warnings and -suppress-remarks; this patch
adds support for suppressing notes too. Doing so is useful for -verify
tests where we don't really care about the emitted notes.
2025-10-06 17:05:57 -07:00
Henrik G. Olsson
5519be8b7c Move span to conditional header in libstdc++ module map
`span` is not available in all versions of libstd++, so make it a
conditional header. Also adds other missing c++20 headers.

Fixing this triggered an assert when importing a constant initialized
`wchar_t` variable, so that is also fixed. The reason is that `wchar_t`
is mapped to `Unicode.Scalar`, which cannot be directly initialized by
integer literals in Swift, triggering an assert when looking up the
protocol conformance for `_ExpressibleByBuiltinIntegerLiteral`.

rdar://162074714
2025-10-06 16:02:35 -07:00
Andrew Trick
7818b8c0df Merge pull request #84702 from atrick/builtin-nonescapable
Allow Builtin.Load/Take -> ~Escapable
2025-10-06 14:27:59 -07:00
Hamish Knight
d65f28984a [CS] Improve diagnostics for non-metatype type(of:) contextual type
Emit a custom diagnostic for this case, and handle holes.
2025-10-06 21:45:48 +01:00
Andrew Trick
c2171ea9b0 Merge pull request #84703 from atrick/lifedep-diag-init
Lifetimes: add a diagnostic note for implicit accessors
2025-10-06 12:29:51 -07:00
Hamish Knight
6d7d1d78d6 Merge pull request #84695 from hamishknight/typewriter
[AST] Canonicalize original type for ErrorType
2025-10-06 17:23:55 +01:00
Erik Eckstein
8efafc7e3b Optimizer: remove the -experimental-swift-based-closure-specialization option 2025-10-06 12:02:48 +02:00
Erik Eckstein
259bf65fc9 SIL: remove the now unused SILFunctionType_isTrivialNoescape bridging function 2025-10-06 12:02:48 +02:00
Erik Eckstein
df20d36255 ClosureSpecialization: support for OSSA and a big overhaul
Beside supporting OSSA, this change significantly simplifies the pass.
The main change is that instead of starting at a closure (e.g. `partial_apply`) and finding all call sites, we now start at a call site and look for closures for all arguments. This makes a lot of things much simpler, e.g. not so many intermediate data structures are required to track all the states.

I needed to remove the 3 unit tests because the things those tests were testing are not there anymore. However, the pass is tested with a lot of sil tests (and I added quite a few), which should give good test coverage.

The old ClosureSpecializer pass is still kept in place, because at that point in the pipeline we don't have OSSA, yet. Once we have that, we can replace the old pass withe the new one.
However, the autodiff closure specializer already runs in the OSSA pipeline and there the new changes take effect.
2025-10-06 12:02:48 +02:00
Erik Eckstein
89bba668e2 Mangling: add a closure specialization mangling for arguments which specialize for the same closure as a previous argument
For example:
```
  %1 = partial_apply %closure
  apply %f(%1, %1)    // first argument: `.closure(%1)`
                      // second argument: `.previousArgumentIndex(0)`
```
2025-10-06 09:47:41 +02:00
Erik Eckstein
272fd224b2 SILCloner: support cloning the whole function if the client already provided the cloned entry block 2025-10-06 09:47:41 +02:00
Erik Eckstein
08696eeb92 Cloner: set the cloner's builder insertion point to the entry block when creating a new entry block in the cloned function
This allows clients to directly clone specific instructions into the new entry block
2025-10-06 09:47:40 +02:00
Erik Eckstein
898b8754bf SIL: add some Instruction/Builder APIs
* `var UncheckedValueCastInst.fromValue`
* `BeginApplyInst.isNonThrowing` and `BeginApplyInst.isNonAsync`
* `Builder.createUncheckedValueCast`
2025-10-06 09:47:40 +02:00
Andrew Trick
c494124d11 Allow Builtin.Take -> ~Escapable 2025-10-05 20:17:47 -07:00
Andrew Trick
771e9b522e Lifetimes: add a diagnostic note for implicit accessors
Lifetime diagnostics may report an error within an implicit initializer or
accessor. The source location is misleading in these cases and causes much
consternation.
2025-10-05 20:16:44 -07:00
Hamish Knight
f643f3d990 [Evaluator] Add "through" to "declared here" request cycle notes
Make it a bit clearer that these are steps in the request cycle.
2025-10-05 20:48:08 +01:00
Hamish Knight
13023de4c4 [Evaluator] Avoid emitting duplicate "through reference here" notes
Filter out any duplicate notes to help cut down on the noise for
request cycle diagnostics. Some of the note locations here still aren't
great, but this at least stops us from repeating them for each
intermediate request.
2025-10-05 20:48:08 +01:00
Hamish Knight
382a52ed2f [AST] NFC: Add Diagnostic::getLocOrDeclLoc 2025-10-05 20:48:08 +01:00
Slava Pestov
811a201bc1 Merge pull request #84675 from slavapestov/rqm-protocol-failure-bookkeeping
RequirementMachine: New way of propagating failure when building rewrite system for protocol
2025-10-05 14:10:00 -04:00
Hamish Knight
7465928b45 [AST] Canonicalize original type for ErrorType
Make sure we canonicalize the original type for an ErrorType to ensure
that diagnostic logic can coalesce ErrorTypes that have the same
canonical type.
2025-10-05 11:19:59 +01:00
Hamish Knight
d06d12632b Merge pull request #84666 from hamishknight/can-opener
[CS] Consolidate placeholder handling logic into `Solution::simplifyType`
2025-10-04 22:55:38 +01:00
Henrik G. Olsson
e0c65b7c44 [DiagnosticVerifier] Add -verify-ignore-unrelated flag
This adds the implementation required for later changing the default
behaviour of the -verify flag to error when diagnostics are emitted
in buffers other than the main file and files added with
-verify-additional-file. To keep the current behaviour, use the flag
-verify-ignore-unrelated. This flag is added as a no-op so that tests
can start using it before the new behaviour is enabled by default.
2025-10-04 12:40:59 -07:00
Slava Pestov
244d2afea3 RequirementMachine: New way of propagating failure when building rewrite system for protocol
If we failed to construct a rewrite system for a protocol, either because
the Knuth-Bendix algorithm failed or because of a request cycle while
resolving requirements, we would end up in a situation where the resulting
rewrite system didn't include all conformance requirements and associated
types, so name lookup would find declarations whose interface types are
not valid type parameters.

Fix this by propagating failure better and just doing nothing in
getReducedTypeParameter().

Fixes rdar://147277543.
2025-10-04 09:17:46 -04:00
Hamish Knight
9e4208b69b [CS] Remove custom logic from simplifyTypeForCodeCompletion
We ought to be able to just use `simplifyType` with an additional
parameter to tell it to produce archetypes.
2025-10-04 12:56:52 +01:00
Henrik G. Olsson
ed4f058c01 Merge pull request #84507 from hnrklssn/swiftify-import-as-method
[Swiftify] Add support for free functions imported as instance methods
2025-10-04 00:40:00 -07:00
Doug Gregor
cd7924a273 Merge pull request #84682 from DougGregor/embedded-deferred-code-gen-external-symbols 2025-10-03 22:32:47 -07:00