Commit Graph

47194 Commits

Author SHA1 Message Date
Erik Eckstein
bb3b0b2859 Optimizer: remove the old CapturePropagation pass 2025-09-04 08:15:47 +02:00
Erik Eckstein
efa9f9ebc0 Optimizer: rewrite and improve the ConstantCapturePropagation pass
(old name: CapturePropagation)

The pass is now rewritten in swift which makes the code smaller and simpler.
Compared to the old pass it has two improvements:

* It can constant propagate whole structs (and not only builtin literals). This is important for propagating "real" Swift constants which have a struct type of e.g. `Int`.
* It constant propagates keypaths even if there are other non-constant closure captures which are not propagated. This is something the old pass didn't do.

rdar://151185177
2025-09-04 08:15:46 +02:00
Erik Eckstein
8e86b5ce3b Optimizer: add a preserveGenericSignature flag to FunctionPassContext.createSpecializedFunctionDeclaration 2025-09-04 08:15:46 +02:00
Erik Eckstein
45b1a21e74 Optimizer: make ModulePassContext.specialize() also available in FunctionPassContext and add two argument flags
add `convertIndirectToDirect` and `isMandatory`
2025-09-04 08:15:45 +02:00
Erik Eckstein
b8a49692eb Optimizer: add TypeSubstitutionCloner and func cloneAndSpecializeFunction
Also move `func cloneFunction` from ContextCommon.swift to OptUtils.swift
2025-09-04 08:15:45 +02:00
Erik Eckstein
c15f76f316 SILCloner: correctly map function argument types in cloneFunction
and remove the now unused `SILBasicBlock::cloneArgumentList`
2025-09-04 08:15:45 +02:00
Erik Eckstein
231042b9a8 SIL: some Cloner cleanups and improvements
* move some Cloner utilities from ContextCommon.swift directly into Cloner.swift
* add an `cloneRecursively` overload which doesn't require the `customGetCloned` closure argument
* some small cleanups
2025-09-04 08:15:45 +02:00
Erik Eckstein
65d69fe965 SIL/AST: add some APIs
* `GenericSignature.isEmpty`
* `Builder.emitDestroy`
* `Function.abi`
* `KeyPathInst.substitutionMap`
* `KeyPathInst.hasPattern`
2025-09-04 08:15:44 +02:00
Erik Eckstein
1a4bd76f95 Mangling: add specialization mangling for more complex constant propagated function arguments
So far, constant propagated arguments could only be builtin literals.
Now we support arbitrary structs (with constant arguments), e.g. `Int`.
This requires a small addition in the mangling scheme for function specializations.
Also, the de-mangling tree now looks a bit different to support a "tree" of structs and literals.
2025-09-04 08:15:44 +02:00
Erik Eckstein
bc244d1122 SIL: move the FunctionBuilderTy template argument from TypeSubstCloner to remapParentFunction 2025-09-04 08:15:44 +02:00
Andrew Trick
ada46a0cf0 Lifetime inference: restructure to support multiple dependencies.
Restructure the inference logic to allow the same function declaration to
independently annotate or infer different lifetime targets.

For example:

   @_lifetime(borrow a)
   /* DEFAULT: @_lifetime(b: copy b)
   func f(a: A, b: inout B) -> NE

The fact that we prevented this was somewhat accidental and surprising.

This restructuring simplifies the code but also gives us much more control over
the inference logic.

Fixes: rdar://159288750 ("A function cannot have a ~Escapable 'inout' parameter
in addition to other ~Escapable parameters" is not actionable)
2025-09-03 22:42:12 -07:00
Artem Chikin
293439429e Merge pull request #84064 from artemcm/DepScanWorkersNoShareDiagEngine
[Dependency Scanning] Give each scanner worker a unique Diagnostic Engine
2025-09-04 01:01:27 -04:00
Doug Gregor
ed93b46fa6 [Embedded] Introduce DeferredCodeGen feature.
Introduce an experimental feature DeferredCodeGen, that defers the
generation of LLVM IR (and therefore object code) for all entities
within an Embedded Swift module unless they have explicitly requested
to not be emitted into the client (e.g., with
`@_neverEmitIntoClient`).

This feature is meant to generalize and subsume
-emit-empty-object-file, relying on lazy emission of entities rather
than abruptly ending the compilation pipeline before emitting any IR.

Part of rdar://158363967.
2025-09-03 15:55:47 -07:00
Artem Chikin
1cd1193e6c [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:52:44 -07:00
swift-ci
255ee32c29 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-03 13:48:19 -07:00
Pavel Yaskevich
0bcc9560b9 Merge pull request #83886 from janbaig/temp-branch
[SILGen] Remove and replace ad-hoc `assign_by_wrapper` instruction
2025-09-03 13:37:43 -07:00
swift-ci
902cdd0cbc Merge remote-tracking branch 'origin/main' into rebranch 2025-09-03 13:11:32 -07:00
Allan Shortlidge
a4da07efc5 Merge pull request #84070 from tshortli/universally-unavailable-at-runtime
AST: Fix runtime unavailability for universally unavailable decls
2025-09-03 12:45:49 -07:00
swift-ci
7395dd8af2 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-03 12:20:00 -07:00
Hamish Knight
7fb532e4e6 Merge pull request #83776 from hamishknight/the-diags-never-stop-no
[Diags] Allow multiple in-flight diagnostics
2025-09-03 19:59:44 +01:00
swift-ci
b467918d69 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-03 09:17:14 -07:00
Allan Shortlidge
707c4aa52c AST: Factor out a utility for computing runtime unavailability.
In anticipation of needing to compute runtime unavailability to determine
whether declarations should be printed in swiftinterfaces, factor out the code
that computes runtime unavailability into a shared utility based on
`DeclAvailabilityConstraints`.

NFC.
2025-09-02 23:18:05 -07:00
Allan Shortlidge
91ddf93d0f Sema: Introduce an ExportabilityReason for availability attributes.
This allows diagnostics to be more precise and will also support logic that
allows for special cases for `@available` attributes in exportability checking.

Also fixes a bug where the exportability of `@available` attributes attached to
extensions were diagnosed twice for slightly differing reasons.
2025-09-02 23:13:08 -07:00
Janat Baig
f21eb5375e Merge branch 'main' into temp-branch 2025-09-02 20:23:25 -04:00
swift-ci
f22cb818d1 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-02 03:16:50 -07:00
Alastair Houghton
9805bd8f81 Merge pull request #84046 from al45tair/eng/PR-158728756
[Reflection] Fix task reflection to strip signed pointers.
2025-09-02 08:47:23 +01:00
swift-ci
7563fa5023 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-01 14:03:12 -07:00
Hamish Knight
3cc52dc4c7 Merge pull request #84042 from hamishknight/too-complex-log
[CS] Add debug message when hitting too complex limit
2025-09-01 19:14:10 +01:00
swift-ci
1f5d273e56 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-01 10:37:09 -07:00
Gábor Horváth
ade5c6a058 Merge pull request #82616 from swiftlang/gaborh/attr-hide-swift-decls
[cxx-interop] Add attribute to hide Swift declarations from interop
2025-09-01 18:15:44 +01:00
Alastair Houghton
b2e2bd2f9d [Reflection] Fix task reflection to strip signed pointers.
The task resume context may be signed, so we should strip the pointer
before trying to read through it.

rdar://158728756
2025-09-01 17:04:05 +01:00
Hamish Knight
0142d0b92e [CS] Add debug message when hitting too complex limit
Add a message to the constraints debugging log when hitting one of the
complexity limits.
2025-09-01 13:33:47 +01:00
Gabor Horvath
7ac9a81b1e [cxx-interop] Add attribute to hide Swift declarations from interop
This can help work around problems when the names of a C++ declaration
and a Swift declaration would collide, or to temporarily work around
compiler bugs.

rdar://152838988&140802127&158843666
2025-09-01 12:29:34 +01:00
swift-ci
ac529bd9df Merge remote-tracking branch 'origin/main' into rebranch 2025-09-01 02:37:16 -07:00
Jakub Florek
eae7864370 Merge pull request #83988 from MAJKFL/new-sil-licm-pass-copy
New SIL LICM pass
2025-09-01 10:28:17 +01:00
swift-ci
1be6ce5e99 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-01 01:35:51 -07:00
Hamish Knight
57ae9ded43 Merge pull request #84030 from hamishknight/hole-in-one
[CS] Avoid unnecessary type variables when opening ErrorTypes
2025-09-01 09:25:30 +01:00
swift-ci
69e3469a9f Merge remote-tracking branch 'origin/main' into rebranch 2025-08-31 03:55:05 -07:00
Hamish Knight
a1e4a08ac7 Merge pull request #83593 from hamishknight/disable-fallback
[IDE] Remove fallback type-checking logic
2025-08-31 10:09:22 +01:00
swift-ci
962a58dec4 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-30 22:35:31 -07:00
eeckstein
c2cd172860 Merge pull request #83999 from eeckstein/access-enforcement-improvements
Optimizer: some small fixes and improvements for exclusivity checking
2025-08-31 07:22:00 +02:00
swift-ci
214fc8cdf6 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-30 11:36:49 -07:00
eeckstein
50b5ecf042 Merge pull request #84013 from eeckstein/canonical-substitution-maps
SIL: only use canonical substitution maps in SIL
2025-08-30 20:30:07 +02:00
Hamish Knight
ff200137a8 [AST] Add ErrorType originator for PlaceholderType 2025-08-30 16:05:01 +01:00
Hamish Knight
d7fea157a1 [IDE] Remove fallback type-checking logic
This should no longer be necessary, rip it out.
2025-08-30 14:08:42 +01:00
Erik Eckstein
3de5d6a13e SIL: add get+set for enforcement in BeginAccessInst 2025-08-30 07:29:15 +02:00
swift-ci
1b057c0958 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-29 20:59:22 -07:00
Michael Gottesman
391ad21583 [rbi] Make all PartitionOpErrors noncopyable types.
I am going to be adding support to passes for emitting IsolationHistory behind a
flag. As part of this, we need to store the state of the partition that created
the error when the error is emitted. A partition stores heap memory so it makes
sense to make these types noncopyable types so we just move the heap memory
rather than copying it all over the place.
2025-08-29 15:18:55 -07:00
Adrian Prantl
98370c30ae Use std::map::insert to avoid a call to std::piecewise_construct (NFC) 2025-08-29 15:12:34 -07:00
swift-ci
93688bfe95 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-29 14:57:15 -07:00