Commit Graph

6703 Commits

Author SHA1 Message Date
Kavon Farvardin
9eba052ab2 Merge pull request #74322 from kavon/se427-noimplicit-for-invertible
SE-427: Make conditional conformances to Copyable more explicit.
2024-06-12 22:03:49 -07:00
nate-chandler
6694bbab90 Merge pull request #74360 from nate-chandler/rdar127518559
[ConsumeAddrChecker] Diagnose consumes of borrows.
2024-06-12 20:33:07 -07:00
nate-chandler
e431216db3 Merge pull request #74343 from nate-chandler/gh73525
[Test] Add regression test.
2024-06-12 15:19:52 -07:00
Kavon Farvardin
ec4a125f3e NCGenerics: ext's might not infer invertible req's
If the extension adds conformance to an invertible protocol, it's
confusing for people to also infer conditional requirements on the
generic parameters for those invertible protocols. This came up in the
review of SE-427.
2024-06-12 14:44:22 -07:00
Nate Chandler
cc40e29f2c [ConsumeAddrChecker] Diagnose consumes of borrows.
When checking a `mark_unresolved_move_addr` instruction, first check
whether it is legal to consume the source.

rdar://127518559&125817827
2024-06-12 13:13:45 -07:00
eeckstein
b7b93a12a0 Merge pull request #74329 from eeckstein/fix-block-cloning
SIL: update borrowed-from instructions when cloning a basic block
2024-06-12 20:38:13 +02:00
Nate Chandler
c9e2e8e66c [Test] Add regression test.
For https://github.com/apple/swift/issues/73525 .
2024-06-12 09:07:02 -07:00
nate-chandler
3aca85bfb3 Merge pull request #74298 from nate-chandler/rdar129593468
[NoncopyableWrapperElim] Process undef values.
2024-06-12 06:55:48 -07:00
Erik Eckstein
d80813ee3b SIL: update borrowed-from instructions when cloning a basic block
Cloning blocks might split CFG edges which can "convert" terminator result arguments to phi-arguments.
In this case a borrowed-from instruction must be inserted.

Fixes a SIL verifier crash caused by SimplifyCFG's jump threading.
rdar://129187525
2024-06-12 12:56:34 +02:00
nate-chandler
43ce060155 Merge pull request #74309 from nate-chandler/rdar129622373
[ClosureSpecializer] Bail on noncopyable argument.
2024-06-11 21:24:21 -07:00
Nate Chandler
5d63fcfef6 [MOWTE] Visit undef values.
Such values' types may also also be move-only wrapped.
2024-06-11 17:02:36 -07:00
Meghana Gupta
f1a887515b Merge pull request #74195 from meg-gupta/immortal
Add dependsOn(immortal)
2024-06-11 15:51:34 -07:00
Nate Chandler
ac5ae3cc2a [ClosureSpecializer] Bail on noncopyable argument.
The optimization currently always creates a retain of the argument.
This isn't legal for noncopyable values.

rdar://129622373
2024-06-11 14:57:23 -07:00
Meghana Gupta
c14559173d Add dependsOn(immortal) 2024-06-11 11:18:10 -07:00
Slava Pestov
5dbf31a5d3 Merge pull request #74266 from slavapestov/fix-rdar129298104
SIL: Consistently drop substitution map when forming apply instructions
2024-06-11 13:45:01 -04:00
Joe Groff
210ded13cf Merge pull request #74270 from jckarter/move-only-tsan-test-require
Run moveonly checker + TSAN tests in a separate file.
2024-06-11 08:08:32 -07:00
Slava Pestov
322ce5a1ab SIL: Consistently drop substitution map when forming apply instructions
Fixes rdar://129298104.
2024-06-11 10:36:15 -04:00
eeckstein
8dec8f6058 Merge pull request #74259 from eeckstein/fix-fixed-abi-runtime-effects
PerformanceDiagnostics: avoid false meta-data alarms for non-loadable types
2024-06-11 07:26:34 +02:00
Joe Groff
03e0cfdf7a Run moveonly checker + TSAN tests in a separate file.
TSAN is not supported on all targets, so covering TSAN in the same file as the
core tests makes them unnecessarily nonportable. rdar://129286269
2024-06-10 14:37:58 -07:00
nate-chandler
77437410be Merge pull request #74235 from nate-chandler/rdar127115078
[SILGen] Forward address-only self to borrowing accessors.
2024-06-10 14:02:21 -07:00
Erik Eckstein
717880e844 PerformanceDiagnostics: avoid false meta-data alarms for non-loadable types
Non-loadable types don't necessarily need metadata, for example, structs with `@_rawLayout`

https://github.com/apple/swift/issues/73951
2024-06-10 18:25:08 +02:00
Doug Gregor
25830d6bc3 Merge pull request #74225 from DougGregor/flow-sensitive-actor-init-isolation
Teach `#isolation` to respect the flow-sensitive nature of actor initializers
2024-06-10 01:52:38 -07:00
Doug Gregor
d1ae73f436 Handle flow-sensitive #isolation in distributed actor initializers.
Distributed actors can be treated as actors by accessing the `asLocalActor`
property. When lowering `#isolation` in a distributed actor initializer,
use a separate builtin `flowSensitiveDistributedSelfIsolation` to
capture the conformance to `DistributedActor`, and have Definite
Initialization introduce the call to the `asLocalActor` getter when
needed.
2024-06-09 22:48:43 -07:00
Nate Chandler
e3fbad50fe [SILGen] Forward addr self to borrow accessors.
Utilize and expand the pre-existing peephole.

rdar://127115078
2024-06-08 10:15:08 -07:00
Doug Gregor
814a093ef2 Fixup test 2024-06-07 16:53:15 -07:00
Doug Gregor
956243cd7e Teach #isolation to respect the flow-sensitive nature of actor initializers
Actor initializers have a flow-sensitive property where they are isolated
to the actor being initialized only after the actor instance itself is
fully-initialized. However, this behavior was not being reflected in
the expansion of `#isolation`, which was always expanding to `self`,
even before `self` is fully formed.

This led to a source compatibility issue with code that used the async
for..in loop within an actor initializer *prior* to the point where the
actor was fully initialized, because the type checker is introducing
the `#isolation` (SE-0421) but Definite Initialization properly rejects
the use of `self` before it is initialized.

Address this issue by delaying the expansion of `#isolation` until
after the actor is fully initialized. In SILGen, we introduce a new
builtin for this case (and *just* this case) called
`flowSensitiveSelfIsolation`, which takes in `self` as its argument
and produces an `(any Actor)?`. Definite initialization does not treat
this as a use of `self`. Rather, it tracks these builtins and
replaces them either with `self` (if it is fully-initialized at this
point) or `nil` (if it is not fully-initialized at this point),
mirroring the flow-sensitive isolation semantics described in SE-0327.

Fixes rdar://127080037.
2024-06-07 14:54:20 -07:00
Joe Groff
6210c2e9d2 Merge pull request #74187 from jckarter/moveonly-wrapped-type-eliminator-missing-case
Add missing OpenExistentialAddr no-changes-needed case to MoveOnlyWrappedTypeEliminator.
2024-06-07 07:57:09 -07:00
nate-chandler
033fc2354f Merge pull request #74157 from nate-chandler/rdar128710064
[SILGen] Store_borrow into in_guaranteed.
2024-06-07 06:47:16 -07:00
Joe Groff
49aac80da8 Add missing OpenExistentialAddr no-changes-needed case to MoveOnlyWrappedTypeEliminator.
Fixes rdar://126875325.
2024-06-06 13:06:24 -07:00
Nate Chandler
000a33f04f [MoveOnlyAddressChecker] Don't destroy borrows.
If a marked location is used by `store_borrow`s, then all its users are
`store_borrow`s or `dealloc_stack`s, so there's nothing to destroy.
2024-06-06 11:20:16 -07:00
Joe Groff
efc193ffa3 Merge pull request #74154 from jckarter/treat-reinit-attempts-in-multi-block-defers-as-errors
Turn mishandled reinitialize-in-`defer`-after-`consume` cases into errors.
2024-06-05 21:04:34 -07:00
nate-chandler
69d2006bfb Merge pull request #74152 from nate-chandler/rdar129299803
[DCE] Insts that define lexical values seem useful
2024-06-05 20:32:35 -07:00
nate-chandler
40e8b155b0 Merge pull request #73859 from nate-chandler/lifetime-completion/20240523/1
[LifetimeCompletion] Mark lifetimes in dead-end loops.
2024-06-05 20:01:45 -07:00
Alex Lorenz
5aa63fc93e Merge pull request #72634 from hyp/eng/android/ndk-overlay
[android] add an Android NDK Swift overlay
2024-06-05 19:35:13 -07:00
Nate Chandler
84da0ed4c5 [LifetimeCompletion] Add extend_lifetimes.
The new instructions are inserted after every "user" (according to
InteriorLiveness' SSAPrunedLiveness instance) outside the linear
liveness boundary.
2024-06-05 16:28:28 -07:00
Nate Chandler
087bf6a75b [LifetimeCompletion] NFC: Add helper.
It visits users discovered by an SSAPrunedLiveness instance (such as
that used by InteriorLiveness) which are outside the LinearLifetime
boundary.
2024-06-05 16:28:28 -07:00
Nate Chandler
81fa65772f [OwnershipLiveness] End at extend_lifetime.
When visiting consumes, also visit `extend_lifetime` instructions.
These instructions are not lifetime ending, but together with the
consumes, they enclose the users of a value.

Add a flag to LinearLiveness to control whether these instructions are
added so that the verifier can use verify that all such instructions
appear outside the linear lifetime boundary (not including them).
2024-06-05 16:28:28 -07:00
Nate Chandler
c2890294e5 [Gardening] Test: Improved match name. 2024-06-05 16:27:45 -07:00
Joe Groff
74aaf88697 Turn mishandled reinitialize-in-defer-after-consume cases into errors.
The handling of multi-basic-block control flow in `defer` blocks looks like it
was left incomplete and completely untested; I fixed a few obvious problems but
it still completely lacks any analysis of conditional reinitializations. For now,
change it to treat attempted reinitializations as uses-after-consumes so we raise
reliable errors now instead of emitting code that causes memory corruption at
runtime. Fixes rdar://129303198.
2024-06-05 14:12:00 -07:00
Nate Chandler
224d36c576 [DCE] Insts that define lexical values seem useful
Don't delete as dead instructions that define lexical values such as
`move_value [lexical]`.

rdar://129299803
2024-06-05 13:04:43 -07:00
nate-chandler
2175abd4e9 Merge pull request #74051 from nate-chandler/test/20240531/1
[Test] Remove -disable-sil-ownership-verifier use.
2024-06-05 10:06:10 -07:00
Doug Gregor
67c0fd8f67 Merge pull request #74133 from DougGregor/mutable-lets-in-inits-tweaks
Tweak "initializable values" logic slightly to address source incompatibilities
2024-06-05 02:28:35 -07:00
Kavon Farvardin
79075e900d Merge pull request #73927 from kavon/ncgenerics-diagnostics-improved
NCGenerics: improve diagnostics
2024-06-04 21:47:01 -07:00
Ellie Shin
c70c52175b Merge pull request #74070 from apple/elsh/pcmo-fixes
[SIL][PackageCMO] Fix dispatch thunk linker error and update table serialization
2024-06-04 18:30:25 -07:00
nate-chandler
23915e8075 Merge pull request #74109 from nate-chandler/rdar113142446
[ConsumeObjectChecker] End lifetimes at consumes.
2024-06-04 18:17:36 -07:00
Doug Gregor
6a8eabf676 Tweak "initializable values" logic slightly to address source incompatibilities
Back of slightly on when we treat a "let" instance property as immutable
within an initializer, to deal with two newly-introduced source
incompatibilities.

Fixes rdar://129253556.
2024-06-04 17:33:26 -07:00
Kavon Farvardin
c9cfe28e6d NCGenerics: improve diagnostics
Removing the old, ad-hoc diagnostics code improves the diagnostics we
emit, since the existing diagnostics for missing conformances is already
pretty good.

rdar://127369509
2024-06-04 15:06:32 -07:00
Ellie Shin
af9e5e6378 Merge branch 'main' into elsh/pcmo-fixes 2024-06-04 11:41:35 -07:00
Ellie Shin
5a0c73c45f Add isPackageCMOEnabled check for MethodInst and KeyPathInst.
Update lambda in table serialization.
Add more tests.
2024-06-03 23:39:04 -07:00
Nate Chandler
04ffbe8a6e [NFC] OwnedValueCan: Add support for end markers.
Enhance the utility with the ability to end lifetimes of lexical values
at indicated instructions, overriding the usual behavior of maintaining
such lifetimes' previous endpoints (modulo non-deinit-barrier
instructions).
2024-06-03 15:45:29 -07:00