Commit Graph

11496 Commits

Author SHA1 Message Date
swift-ci
2deb2f9a87 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-19 22:17:53 -07:00
Kavon Farvardin
889baf7f2c Merge pull request #84411 from kavon/copyprop-onone
sil: provide ability to run CopyPropagation in -Onone
2025-09-19 22:09:59 -07:00
swift-ci
190c612dbf Merge remote-tracking branch 'origin/main' into rebranch 2025-09-19 19:57:32 -07:00
nate-chandler
6cd7974c5a Merge pull request #84405 from nate-chandler/rdar160692694
[DiagnoseStaticExclusivity] Fix this assertion.
2025-09-19 19:37:50 -07:00
Kavon Farvardin
4a943d464d sil: provide ability to run CopyPropagation in -Onone
This does not enable it by default. Use either of the flags:

```
-enable-copy-propagation
-enable-copy-propagation=always
```

to enable it in -Onone. The previous frontend flag
`-enable-copy-propagation=true` has been renamed to
`-enable-copy-propagation=optimizing`, which is currently default.

rdar://107610971
2025-09-19 16:23:19 -07:00
swift-ci
cb01e49f6c Merge remote-tracking branch 'origin/main' into rebranch 2025-09-19 13:58:50 -07:00
Anton Korobeynikov
e6409d7d9d Correctly handle multiple semantic results for autodiff subset differential thunks (#84366)
Fixes https://github.com/swiftlang/swift/issues/84365
2025-09-19 13:54:30 -07:00
Nate Chandler
edf41ceff6 [DiagnoseStaticExclusivity] Fix this assertion.
This function is called in one place in an assertion.  It asserts that
the function in question is the stdlib's swap.  In language mode 6, the
called value may be wrapped in a `function_conversion_expr` for
`@Sendable`.  That's irrelevant for the purposes of this assertion, so
look through such conversions.

rdar://160692694
2025-09-19 11:47:31 -07:00
swift-ci
ca93b4b068 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-18 16:17:26 -07:00
Kavon Farvardin
61fe8a9b8e introduce @_manualOwnership performance attribute
This attribute forces programmers to acknowledge every
copy that is required to happen in the body of the
function. Only those copies that make sense according
to Swift's ownership rules should be "required".

The way this is implemented as of now is to flag each
non-explicit copy in a function, coming from SILGen, as
an error through PerformanceDiagnostics.
2025-09-17 13:51:57 -07:00
swift-ci
0d2c4ca9be Merge remote-tracking branch 'origin/main' into rebranch 2025-09-15 10:29:21 -07:00
Meghana Gupta
c764244df0 Merge pull request #84180 from meg-gupta/borrowandmutatepr
Add preliminary support for borrow accessors
2025-09-15 10:01:15 -07:00
Meghana Gupta
aeac529925 [NFC] Add notes on self argument of borrow accessor being non-lexical 2025-09-14 23:38:18 -07:00
Meghana Gupta
11097c4b9e Avoid inserting lexical scope for arguments of borrow accessors while inlining 2025-09-14 23:38:09 -07:00
Meghana Gupta
a42511e041 [NFC] Replace ApplyInst::getSubstCalleeConv()::hasGuaranteedAddressResult() with ApplyInst::hasGuaranteedAddressResult() 2025-09-14 23:38:07 -07:00
Meghana Gupta
6665cd5d46 [NFC] hasGuaranteedAddressResults -> hasGuaranteedAddressResult and hasGuaranteedResults -> hasGuaranteedResult 2025-09-14 23:38:06 -07:00
Meghana Gupta
29f5dad72f Disable GenericSpecializer for borrow accessors in OSSA temporarily 2025-09-14 23:38:05 -07:00
swift-ci
7f8473a16c Merge remote-tracking branch 'origin/main' into rebranch 2025-09-10 02:51:07 -07:00
Anton Korobeynikov
7668666ad2 Support differentiation of wrapped value modify accessors (#78794)
Some fixes for coroutines with normal results and `partial_apply` of coroutines were required.

Fixes #55084
2025-09-10 02:30:26 -07:00
Meghana Gupta
9e4fa8f508 Updates to MoveOnlyChecker 2025-09-09 14:45:45 -07:00
Meghana Gupta
1cff471c57 Introduce ResultConvention::Guaranteed and ResultConvention::GuaranteedAddress
ResultConvention::Guaranteed will be used by borrow accessors when the storage type can be returned by value.

ResultConvention::GuaranteedAddress will be used by mutate accessors and borrow accessors when the storage type
cannot be returned by value.
2025-09-09 14:45:40 -07:00
Meghana Gupta
9fe489ce22 Introduce borrow and mutate as new accessor kinds
And handle them in various covered switches
2025-09-09 14:30:26 -07:00
swift-ci
e9979235de Merge remote-tracking branch 'origin/main' into rebranch 2025-09-06 12:18:17 -07:00
John McCall
64d020ec45 [NFC] Introduce a convenience specialization of CanTypeVisitor that
forwards the paired nominal type methods to common implementations.
2025-09-05 14:02:36 -04:00
swift-ci
fe56b8ccf0 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-04 16:41:35 -07:00
Erik Eckstein
844217d58c Optimizer: replace explicit_copy_value and explicit_copy_addr with their non-explicit counterparts
The `explicit_copy_value` and `explicit_copy_addr` instructions are only used for non-copyable diagnostics in the mandatory pipeline.
After that we can replace them by their non-explicit counterparts so that optimizations (which only know of `copy_value` and `copy_addr`) can do their work.

rdar://159039552
2025-09-04 19:40:53 +02:00
Anthony Latsis
e1450e011e Manually merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
*	utils/build_swift/build_swift/defaults.py
2025-09-04 14:07:50 +01:00
Erik Eckstein
bb3b0b2859 Optimizer: remove the old CapturePropagation pass 2025-09-04 08:15:47 +02:00
Erik Eckstein
ddea9f6aa0 Optimizer: switch to the new ConstantCapturePropagation pass in the pass pipeline 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
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
swift-ci
255ee32c29 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-03 13:48:19 -07:00
Janat Baig
f21eb5375e Merge branch 'main' into temp-branch 2025-09-02 20:23:25 -04:00
swift-ci
0884c83961 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-01 07:14:52 -07:00
nate-chandler
b3af244c46 Merge pull request #84022 from nate-chandler/rdar158139991
[Mem2Reg] Add end_lifetime for more trivial case non-trivial enums.
2025-09-01 06:56:26 -07: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
962a58dec4 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-30 22:35:31 -07:00
Erik Eckstein
86076e2ada RawSILInstLowering: Don't insert an access scope for assign_or_init if there is already one.
This avoids inserting a dynamic access check when the parent is static (and therefore can be statically enforced).
2025-08-30 07:29:14 +02:00
Erik Eckstein
667de83339 Optimizer: move DiagnoseStaticExclusivity after MandatoryAllocBoxToStack
This is needed because MandatoryAllocBoxToStack can convert dynamic accesses to static accesses.
Also, it improves diagnostics for closure captures.
2025-08-30 07:28:33 +02:00
swift-ci
1b057c0958 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-29 20:59:22 -07:00
Nate Chandler
1c52364d28 [Mem2Reg] Complete single-block trivial enum cases
Add `end_lifetime` for values of non-trivial enum type which aren't
destroyed in non-dead-end blocks.
2025-08-29 15:47:10 -07:00
Nate Chandler
4b3588c9b9 [NFC] Mem2Reg: Delete this dead code.
Since the time that lifetimes in `alloc_stack [lexical]` began to be
represented after promotion by `move_value [lexical]`s, the
`endOwnedLexicalLifetimeBeforeInst` is just an assertion.  In the
future, lifetimes of values never destroyed that leak into dead end
blocks should be completed by OSSACompleteLifetime.  For now, just
delete this code.
2025-08-29 15:45:23 -07:00
Nate Chandler
69abf25f3a [NFC] Mem2Reg: Restructured conditional.
In preparation for adding other cases.  Also improved comments.
2025-08-29 15:45:19 -07:00
Nate Chandler
1f7432dedb [Mem2Reg] Don't skip write-only enum locations.
The lifetimes of the values stored into these locations may need to be
completed: if a trivial case of a non-trivial enum is written to the
location, its lifetime must be completed.

rdar://158139991
2025-08-29 15:45:14 -07:00
Nate Chandler
63a3c65147 [Mem2Reg] Fix isStorageValid.
In a few places, it wasn't getting set to false: `end_borrow`s of
`store_borrow`s and `load [take]`s.
2025-08-29 15:45:12 -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
swift-ci
93688bfe95 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-29 14:57:15 -07:00